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

205
Views
No se pueden eliminar los marcadores del mapa del folleto. No usar capas

Acabo de descubrir Leafletjs y me encanta. He estado tratando de eliminar a todos mis creadores cuando mi json está vacío o no es válido y simplemente no puedo hacerlo bien. Todos los diferentes enfoques que probé parpadean/parpadean cada vez que mi json se actualiza y esto es lo más cerca que he logrado estar.

Cualquier ayuda sería genial. Me sorprenden los pocos ejemplos que hay de creadores que se mueven y actualizan sin pestañear... ¡y realmente no quiero usar Google Maps!

Traté de restablecer los creadores = {}; pero esto no hizo nada. Gracias

 data.BMS.forEach(function (obj) { if (obj.lat !== undefined && obj.lng !== undefined) { if (!markers.hasOwnProperty(obj.id)) { markers[obj.id] = new L.Marker([obj.lat, obj.lng], {icon: panicNormal}).addTo(map) .bindTooltip(obj.name, { permanent: true, direction: 'top', offset: [0, 0] }); markers[obj.id].previousLatLngs = []; areaBounds.push([obj.lat, obj.lng]); } else { areaBounds.push([obj.lat, obj.lng]); markers[obj.id].previousLatLngs.push(markers[obj.id].getLatLng()); if(obj.status == "TRUE"){ markers[obj.id].setIcon(panicAlarm); }else{ if(obj.type == "MO"){ markers[obj.id].setIcon(panicNormal); }else{ markers[obj.id].setIcon(lora); } } markers[obj.id].setLatLng([obj.lat, obj.lng]); } }else{ //How do I remove the markers } });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede usar L.FeatureGroup() para agregarle todos los marcadores y luego eliminar todos los marcadores con .clearLayers()

 var fg = L.featureGroup().addTo(map); ... markers[obj.id] = new L.Marker([obj.lat, obj.lng], {icon: panicNormal}).addTo(fg) .bindTooltip ... }else{ //How do I remove the markers fg.clearLayers(); }
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!