NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

Hi there

I'm looking for an easy solution how to add to my OpenStreetMap the icon to get my current position and retrive latitude and longitude.

Thanks in advance for your help. Please keep ion mind when relying that I'm a nook.

best regards


asked 13 Oct '20, 10:28

Ossy01's gravatar image

accept rate: 0%

edited 13 Oct '20, 10:54

TZorn's gravatar image


Can you explain in a bit more detail what you mean by "my OpenStreetMap"? If a generic website, try one of .

(13 Oct '20, 10:35) SomeoneElse ♦

Sorry about not being clear. Here is my Page. <html><body>

<script src=""></script> <script> var mylat = 46.9 var mylon = 6.6833 map = new OpenLayers.Map("mapdiv"); map.addLayer(new OpenLayers.Layer.OSM());

var lonLat = new OpenLayers.LonLat( mylon,mylat )
        new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
        map.getProjectionObject() // to Spherical Mercator Projection

var zoom=17;

var markers = new OpenLayers.Layer.Markers( "Markers" ); map.addLayer(markers);

markers.addMarker(new OpenLayers.Marker(lonLat));

map.setCenter (lonLat, zoom);

</script> </body></html>

I would lite to add under the zoom the icon for geo-location, center the map to this location and retrieve the information in my javascript. I have seen some script, but I didn't work for me. Perhars not used corretly.

++ Ossy

(13 Oct '20, 10:49) Ossy01

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 13 Oct '20, 10:28

question was seen: 1,572 times

last updated: 13 Oct '20, 10:54

NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum