Skip to content Skip to sidebar Skip to footer

Postgresql Geojson <- Php -> Javascript

I'm in the throes of re-building something that built almost a year ago (don't ask where the old version went - it's embarrassing). The core functionality uses an $.getJSON (ajax-i

Solution 1:

It seems that you are missing the cast to json. It should be

ST_AsGeoJSON(ST_Transform(lg.g1,4326))::json

Without the cast, st_asgeojson returns a string, that is double-encoded.

However, you could also get attributes and geoJson, than json_decode the json with PHP, create a geoJson featurecollection array with php, and finally json_encode the whole result.

Post a Comment for "Postgresql Geojson <- Php -> Javascript"