2
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 1

3

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.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.