I am trying to display the GIS data on the Google map using PostgreSQL.
I have few shapefiles, I imported those shapefile into PostgreSQL. Now I am trying to get this data using this query. After running the query I am getting such type of GeoJSON form PostgreSQL I found that the data retrieved from PostgreSQL is not proper format as Google Maps accepted. The data is in another format please see my GeoJSON data:
$query="SELECT ST_AsGeoJSON(ST_Transform(geom, 4326)) AS geom_in_degrees FROM pymble_10 ";
$result = pg_query($db, $query);
$finalArray = array();
$i=0;
while($row=pg_fetch_row($result)){
print_r($row);
}
And I am getting output like this :
Array ( [0] =>
{"type":"MultiPolygon","coordinates":[[[[16826527.7094727,-3992350.20318604],[16826530.7548828,-3992351.11029053],[16826532.8928833,-3992352.14691162],[16826534.1887207,-3992353.50750732],[16826535.0958862,-3992355.12738037],[16826535.7437134,-3992356.68231201],[16826535.8084717,-3992357.97821045],[16826535.6140747,-3992359.27398682],[16826534.9663086,-3992360.50512695],[16826534.059082,-3992361.47698975],[16826532.9577026,-3992362.3192749],[16826531.6619263,-3992362.83758545],[16826530.4309082,-3992362.96722412],[16826528.4871216,-3992363.355896],[16826527.2561035,-3992363.6151123],[16826524.145874,-3992364.32788086],[16826521.9431152,-3992365.04058838],[16826520.4528809,-3992365.23492432],[16826518.6386719,-3992364.97570801],[16826517.3428955,-3992363.6151123],[16826516.1118774,-3992361.2177124],[16826516.046875,-3992358.95001221],[16826516.3060913,-3992357.07110596],[16826517.1484985,-3992355.58081055],[16826518.8331299,-3992353.5723877],[16826520.2584839,-3992352.01739502],[16826521.3599243,-3992350.65667725],[16826522.3319092,-3992350.00878906],[16826524.0812988,-3992349.87921143],[16826527.7094727,-3992350.20318604]]]]} )
print_r
is only used for debugging. You need to usejson_encode
instead. Additionally, check your geometries; The coordinates seem outside the normal domain of lat-long