This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

How can I get latitude and longitude when user selects location on a map?

0

Hi,

I would like to capture latitude and longitude (or another searchable geocoding mechanism) when a user enters an address or selects a location on a map.

How can I do this?

Thanks, Jim

asked 07 Nov '22, 00:10

jtappe's gravatar image

jtappe
11112
accept rate: 0%


One Answer:

0

If you browse the map or do an address search the Lat Long are the co-ords of the screen center. Lat lon is highlighted.

alt text

answered 07 Nov '22, 09:52

andy%20mackey's gravatar image

andy mackey
13.2k87143285
accept rate: 4%

edited 07 Nov '22, 10:41

Note : OSM represents South and West as negative numbers. With lat long North is a positive south is negative (-) East is positive, West is negative (-)

(07 Nov '22, 09:59) andy mackey

Source code available on GitHub .