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
  • ty its working :) Commented Apr 29, 2016 at 19:49

Your Answer

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

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