Alex Rivera | Logout

Convert lat long into geojson object

Asked 2011-04-11T11:38:41.607
9

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

Edit
Report

1 Answer

17

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]
 }
answered 2011-04-11T11:55:12.900

Your Answer