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

161
Views
¿Cómo configurar la opacidad del marcador de folleto?

estoy trabajando con map api. trato de ocultar el marcador si el nivel de zoom está por debajo de 15 y mostrar el marcador si el nivel de zoom es más de 15. aquí está mi código:

 const markerS = L.marker([0, 0], {icon: start}).addTo(mymap); const api_url = 'json.php' async function getjson() { const response = await fetch(api_url); const data = await response.json(); const start = (data[0]) const zoom = mymap.getZoom(); markerS.setLatLng([start.latitude, start.longtitude]); if(zoom > 15) { markerS.style.display == "block" } else { markerS.style.display = "none" } }

pero la lógica if no funciona. el archivo console.log muestra "Error de tipo no capturado (en promesa): no se pueden establecer propiedades de undefined (configurando 'display') en getjson"

¿Cómo puedo arreglar esto?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Las instancias de marcador de folleto no son elementos DOM, no tienen una propiedad .style . Sin embargo, tienen un método setOpacity .

Cambio

 markerS.style.display == "block" markerS.style.display = "none"

a

 markerS.setOpacity(100); markerS.setOpacity(0);

respectivamente.

about 4 years ago · Juan Pablo Isaza Report
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!