Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

127
Views
HTML: cree una tabla interactiva con varios botones de radio, que pueden mostrar diferentes mapas creados por MapBox

Traté de usar HTML para crear una tabla interactiva de mapas, que puede mostrar varios mapas diferentes de MapBox. Creé una tabla con algunos botones de radio, como:

 <table> <tr> <td> <input type="radio" name="layers" id="layer1" value="2000" checked><label>2000 &nbsp; &nbsp;</label> <input type="radio" name="layers" id="layer2" value="2008"><label>2008 </label> </td> </tr> </table>

Y luego, importé mapas de MapBox por:

 mapboxgl.accessToken = 'mytoken'; //Put your mapbox access token here var map1 = new mapboxgl.Map({ //container: 'map', // container id style: 'mapbox_stylelink', // map background layer location center: [0, 51.5], // starting position [lng, lat] zoom: 10, // starting zoom pitch: 50 // tilt of the viewpoint in degrees }); var map2 = mapboxgl.Map({ //container: 'map', // container id style: 'mapbox_stylelink', // map background layer location center: [0, 51.5], // starting position [lng, lat] zoom: 8, // starting zoom pitch: 50 // tilt of the viewpoint in degrees });

E intente devolver la llamada al oyente:

 document.getElementById("layer1").addEventListener("click", function(){ document.getElementById("map") = 'map1' }); document.getElementById("layer2").addEventListener("click", function () { document.getElementById("map") = 'map2' });

Cuando empiezo a poner en marcha el código, simplemente no puede cambiar el mapa haciendo clic en el botón de 'radio' en la tabla. Sé que hay algo mal con la devolución de llamada, pero no sé cómo corregirlo. Y también parece que el contenedor debería estar vacío al definir un nuevo mapa. ¿Puede alguien darme alguna orientación? ¡Muchas gracias!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!