Estoy usando Leaflet.js en mi proyecto Vue.js 3. En mi aplicación, a medida que el usuario navega por el mapa, se cargan nuevas capas si existen en esa ubicación y me gustaría que las capas antiguas se eliminen si se encuentra nueva información en la ubicación actual. El error que señaló Leaflet ocurre al hacer zoom con una ventana emergente abierta, mostrando:
No se pueden leer las propiedades de nulo (leyendo '_latLngToNewLayerPoint')
Me pregunto si es posible corregir este error sin deshabilitar la animación de zoom y sin cambiar los archivos internos de la biblioteca de folletos.
Fragmento de código citado:
getContributionsAndEMSI: _.debounce(async function (x, y) { let result = await contribution.index(x, y); if (result.success) { this.contributions = result.contribution; } if (this.contributions.length && this.layers.length) { this.layers.forEach((l) => { this.map.removeLayer(l); }); } // Visualização de Contribuições this.contributions.forEach((el) => { const data = '<strong>Colaboração de Usuário</strong><br><hr><br>' + `<strong>Categoria:</strong> ${el.category_name}<br>` + `<strong>Data de ocorrência:</strong> ${el.occurrence || 'Não Informado'}<br>` + `<strong>Vítimas:</strong> ${el.victims ? 'Sim' : 'Não'}<br>` + `<strong>Risco de danos:</strong> ${el.risk_damage ? 'Sim' : 'Não'}<br>` + `<strong>Descrição:</strong> ${el.desc || 'Não Informado'}<br>`; if (wkt.parse(el.local).type === 'Point') { this.layers.push( L.marker(wkt.parse(el.local).coordinates).addTo(toRaw(this.map)).bindPopup(data), ); } if (wkt.parse(el.local).type === 'Polygon') { this.layers.push( L.polygon(wkt.parse(el.local).coordinates).addTo(toRaw(this.map)).bindPopup(data), ); } if (wkt.parse(el.local).type === 'LineString') { this.layers.push( L.polyline(wkt.parse(el.local).coordinates).addTo(toRaw(this.map)).bindPopup(data), ); } }); }); }, 2000), // Espera 2 segundos pra mandar a requisição