NOTICE: help.openstreetmap.org 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

Ossy

asked 13 Oct '20, 10:28

Ossy01's gravatar image

Ossy01
11112
accept rate: 0%

edited 13 Oct '20, 10:54

TZorn's gravatar image

TZorn
12.3k764225

Can you explain in a bit more detail what you mean by "my OpenStreetMap"? If a generic website, try one of https://duckduckgo.com/?t=ffsb&q=html+geolocation&ia=web .

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

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

<script src="http://www.openlayers.org/api/OpenLayers.js"></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 )
      .transform(
        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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×122
×44

question asked: 13 Oct '20, 10:28

question was seen: 1,459 times

last updated: 13 Oct '20, 10:54

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