i need to change a Json string into Geojson format. right now i am using Json_encode() function to convert sql query result into json string (as given in this link JSON encode MySQL results).
i want to make this geojson string readable by openlayers.
how can i use json _encode for this purpose ?
or is there a different function which i can use for this?
thanks in advance.
i need to change a Json string into Geojson format. right now i am
Share
GeoJSON format is fairly simple so I would go ahead and loop through all raw data that your SQL query returns and build a string in GeoJSON format manually. Then you pass this string from you server side code to the client where you parse it to javascript object so that OpenLayers can consume it.
Here’s example in Ruby I’ve done a while ago. Hope you get the idea and can do the same in PHP: