I'm fairly new to Leaflet and just managed to use Leaflet marker-cluster with a JSONP WFS which provides my data from Geoserver. Now I would like to have a popup for my markers by mouse click. But I do not know where to insert the .bindpopup onEachFeature. Maybe I have to rewrite my code, but nothing what I've tried works.
At the end I will have more than 100,000 markers. Any ideas for a good performance?
var markers = L.markerClusterGroup();
var geoJsonLayer = new L.GeoJSON();
var geoJsonUrl ='localhost:8080/geoserver/test/ows';
var defaultParameters = {
service: 'WFS',
version: '1.0.0',
request: 'GetFeature',
typeName: 'test:bh',
maxFeatures: 120000,
outputFormat: 'text/javascript'
};
var parameters = L.Util.extend(defaultParameters);
console.log(geoJsonUrl + L.Util.getParamString(parameters));
$.ajax({
url: geoJsonUrl + L.Util.getParamString(parameters),
dataType: 'jsonp',
jsonpCallback: 'parseResponse',
success: function (data) {
console.log(data);
geoJsonLayer.addData(data);
markers.addLayer(geoJsonLayer);
map.addLayer(markers);
}
});