i need to hand the latlng coordinates from my phpPostGIS-served geoJSONLayer as an array over to a new added HeatMap Layer. L.geoJSON has an build-in option: coordsToLatLng( coords )" and a static method for that: coordsToLatLngs( coords, levelsDeep?, reverse? ).
I don´t get any errors, but the heat map does´t show up. If i build a new L.heatLayer(coord).addTo(map); outside the function, it works…
Does anyone have an idea?
This is what i have so far:
$.getJSON("postgis_geojson.php?geotable=shops&geomfield=the_geom", function(data) {
L.geoJson(data, {
pointToLayer: function (feature, latlng) {
return L.circleMarker(latlng, geojsonMarkerOptions);
},
onEachFeature: function (feature, layer) {
popupOptions = {maxWidth: 200};
layer.bindPopup(feature.properties.popupContent);
},
coordsToLatLng: function (coords) {
return new L.heatLayer(coords);
}
}).addTo(map);
});
Best Answer
In OnEachFeature you can find the coordinates in feature.geometry.coordinates. so
Now you can use the array coords in L.heatLayer