Convert lat long into geojson object

Ashish Pethkar picture Ashish Pethkar · Apr 11, 2011 · Viewed 13.9k times · Source

How can i convert my lat and long value into geojson object. I work on php platform.

Answer

pconcepcion picture pconcepcion · Apr 11, 2011

If I understand well, you want to build a string like this:

$my_geoJSON = '{ "type": "Point", "coordinates": ['.$longitude.' ,'.$latitude.'] }';

As as the specification for GeoJSON format (RFC7946) says:

Point coordinates are in x, y order (easting, northing for projected coordinates, longitude, and latitude for geographic coordinates):

 {
     "type": "Point",
     "coordinates": [100.0, 0.0]
 }