1

I am making an application in java using GMaps4JSF where the person will enter the address on the map I'll take this coordinate and consult on my postgis base regions in which region this point is inserted and return this information on the screen. It's very simple. Google Maps Api uses the Mercator projection (EPSG: 3857), the coordinate of the queried map will be returned in this projection? I must redesign my data to it does not need to do conversions.

1

Although the underlying tiles are projected to epsg:3857, the Maps API accepts Latitude/Longitude pairs in epsg:4326 (vs y/x coordinates in meters, which would be implied by 3857).

Therefore if you want to draw a polygon on the map, you would pass the API latitude/longitude and it will be projected appropriately to match the underlying data (note you may wish to specify geodesic:true in your overlay options in the API)

That said you didn't specify what projection your data in PostGIS is index as, so I can't say whether you need to change anything.

  • I do not want anything to plot on the map. Only'll get coordinated the geocode returns me something like: latLng: (-30.046793600271663, -51.215002834796906) and pass as parãmentro for a postgis query. Have tried with the postgis table in EPSG: 3857 and 4326 and returns nothing. – csf Jun 10 '14 at 18:48
1

Expanding on what Mapperz noted, one way to do this is by creating views in postgresql replacing the geometry field with a calculated field that transforms the coordinate system of your data to a coordinate system that the Maps API can use, 4326 or 3857. Something like:

CREATE OR REPLACE VIEW vw_MY_VIEW AS SELECT ID_FIELD, st_transform(GEOMETRY_FIELD.geometry, 3857) AS geometry, FIELD3, FIELD4 FROM TABLE_NAME;

This would allow you to intersect the point geometry from the map, which is natively 3857, with the view you created, also in 3857.

Alternately you could transform the point geometry from the map into the table's arid in the intersect operation.

This prevents having to reproject and persist your data permanently to meet the needs of a dependency. Instead you can continue to use your postgis data in the coordinate system that best fits your needs.

1

Am not used to Java but I think the Google API's coordinate system can be transformed on render to suite the system of interest.There are two ways to go around this issue: 1. Make sure all the layers in your application are on the same projection. 2. Redefine the projection of one layer to suit another.Example: If your point layers is in EPSG:4326 and want it to overlay on the Google's 3857,you can transform the system to fit the Google's. Hope this helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.