I have managed to show Lat and Lon
function init() {
navigator.geolocation.getCurrentPosition(function(position) {
document.getElementById('myloc').innerHTML="Latitude: " + position.coords.latitude + " Longitude: " +
position.coords.longitude + "<p>";
});
}
now i want this lat and lon on OSM map as a point and whenever i refresh the page, I want the point follows my location…
I added this code in my map function itin
var vectorpoint = new OpenLayers.Layer.Vector("VectorPoint");
map.addLayer(vectorpoint);
var point = new OpenLayers.Geometry.Point(position.coords.longitude ,position.coords.latitude);
vector.addFeatures(new OpenLayers.Feature.Vector(point));
any suggestion?
Best Answer
You could use a marker layer with a image for easy rendering if you only want a simple marker.
Also you will need to center the map to the desired location. With a OpenLayers.Layer.Vector you can do it easily:
To make the "follow" thing you will need a timer to update the feature point regularly.