How can I get the mouseover event to work in my Leaflet.js map?

المشرف العام

Administrator
طاقم الإدارة
I have been trying to follow this mouseover example on the Leaflet.js website but I can't get my test version to work properly. The mouseover works only in some shapes at a time, but the mouseout actually never cleans the change - and the now forever-highlighted polygon becomes one of the few that the mouseover event works everytime.

This is the code I'm using:

window.map = L.map('map').setView([-14, -50], 5); L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { id: 'teste', attribution: '© OpenStreetMap contributors, CC-BY-SA' }).addTo(map); geojson = L.geoJson(dados,{ onEachFeature: onEachFeature } ).addTo(map); function style(feature) { return { fillColor: '#800026', weight: 0.2, opacity: 1, color: 'white', dashArray: '3', fillOpacity: 0.7 }; } L.geoJson(dados, {style: style}).addTo(map) info = L.control(); info.onAdd = function (map) { this._div = L.DomUtil.create('div', 'info'); // create a div with a class "info" this.update(); return this._div; }; info.update = function (props) { if (props) this._div.innerHTML = ''+props.nome_ibge_ + ' - '+props.estado+'


' + ''+ props.populacao_ +'

'; else this._div.innerHTML = '<h2>Passe o mouse sobre uma

أكثر...
 
أعلى