I'm trying to add popups for point icons using Leaflet.js and ran into this error: "Uncaught TypeError: points.eachLayer is not a function"
Here's my code:
function addPoints(data){ for (var feature in data.features){ if(data.features[feature].properties.activity == "hunting"){ points = L.marker([data.features[feature].geometry.coordinates[1],data.features[feature].geometry.coordinates[0]], { icon: L.mapbox.marker.icon({ 'marker-color': '#FF5A5C', 'marker-symbol': 'bus' }) }).addTo(map).on({ mouseover: function(e){ this.openPopup(); }, mouseout: function(e){ this.closePopup(); } }); } }; drawPopup(data);} //end addPointsfunction drawPopup(data){ points.eachLayer(function(layer){ var popupContent = "Park: " + data.features[feature].properties.name + "
" + "Activities: " + data.features[feature].properties.activity; layer.bindPopup(popupContent); });}I've used nearly identical code before and have never run into this problem, what am I doing wrong?
أكثر...
Here's my code:
function addPoints(data){ for (var feature in data.features){ if(data.features[feature].properties.activity == "hunting"){ points = L.marker([data.features[feature].geometry.coordinates[1],data.features[feature].geometry.coordinates[0]], { icon: L.mapbox.marker.icon({ 'marker-color': '#FF5A5C', 'marker-symbol': 'bus' }) }).addTo(map).on({ mouseover: function(e){ this.openPopup(); }, mouseout: function(e){ this.closePopup(); } }); } }; drawPopup(data);} //end addPointsfunction drawPopup(data){ points.eachLayer(function(layer){ var popupContent = "Park: " + data.features[feature].properties.name + "
" + "Activities: " + data.features[feature].properties.activity; layer.bindPopup(popupContent); });}I've used nearly identical code before and have never run into this problem, what am I doing wrong?
أكثر...