I'm trying to display a GeoJSON MultiPolygon object in a Leaflet map. I get it from a PostgreSQL database as a JSON and I trnasform it to a GeoJSON.
I've validated de MultiPolygon object in GeoJSONLint and it's ok:
But I'm not able to accomplish this in my app =(
This is my code:
$http.get(URI_SERVICE+"buscar-clase/"+JSON.stringify(params))
.success(function (data) {
console.log(L.multiPolygon(data.coordinates).toGeoJSON());
adaLayer.clearLayers();
adaLayer = L.geoJson(L.multiPolygon(data.coordinates).toGeoJSON(), {
style: function () {
return {weight: 1, color: "#000000"}
}
});
adaLayer.addTo(map);
}).error(function (err) {
console.log(err);
});
For the record, the map var is working fine, I've printed other layers of GeoJSON.
Give L.geoJSON
the entire payload, not just the coordinates array.
Like
adaLayer = L.geoJson(data, {
style: function () {
return {weight: 1, color: "#000000"}
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With