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

Display GPS position on a website with OSM (Java)

0

Ok here's the story so far... I'm a beginner programmer messing around with the GPS functionality on my browser, Google Chrome. I'm looking at different tutorials for displaying the current location of the user on a website @ W3schools and I decide to see it it were possible to do the same with Open Street Map, instead of Google Maps. How can I utilize the OSM api to take the latitude and longitude returned from my browser? I've messed around with the default iframe offered by the OSM website, but to no avail. Any tips?

asked 05 Jun '15, 13:17

roughlycuboid's gravatar image

roughlycuboid
11112
accept rate: 0%


One Answer:

0

For a bit of background about creating a simple browser-based map that uses map tiles from OSM, have a read of this:

https://switch2osm.org/using-tiles/getting-started-with-leaflet/

Leaflet (the Javascript library) supports a "locate" call - see http://leafletjs.com/reference.html . That allows you to centre the map display using the HTML Geolocation API.

answered 05 Jun '15, 13:31

SomeoneElse's gravatar image

SomeoneElse ♦
36.9k71370866
accept rate: 16%

Source code available on GitHub .