var urlborne = 'http://localhost:8080/geoserver/Gestion-proprete/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=Gestion-proprete:borne&maxFeatures=2000&outputFormat=text/javascript&format_options=callback:getJson&srsName=EPSG:4326';
var Borne = new L.GeoJSON();
$.ajax({
jsonp: false,
url: urlborne,
type: 'GET',
dataType: 'jsonp',
jsonpCallback: 'getJson',
success: function (data) {
console.log(data);
Borne.addData(data);
map.fitBounds(Borne.getBounds());
}
});
1 Answer
You can initialize your Borne
geoJson layer without any data but with a styling function specified in the options:
var Borne = new L.GeoJSON(false, {
style: function (feature) {
return {color: feature.properties.color};
}
});
This style will be applied to any data you add later with addData
.