I try to use the following function to add polygons to my Leaflet map.
function polygon(geojson)
{
alert(geojson); // alert for testing
layer = L.geoJson(geojson);
layer.addTo(map);
}
When I call the above function with the GeoJSON string I fetched from a PostGIS table using ST_AsGeoJSON()
, the following string is alterted.
{"type":"Polygon","coordinates":[[[10,370],[20,380],[30,410],[-10,395],[10,370]]]}
But no polygon shows up on the map. As far as I can say, there is no error message. And I can definitely say that a polygon with the points 10 370, 20 380, 30 410, 10 395
shows up on the map, if I insert it using L.polygon
.
What's wrong?