javascript - Tracking web page via osm(open street map) -
i need create web page track person via open street map in lat-long data sent via app installed on phone. app send lat , long in json file server in database web page take data , show path followed biker in dotted lines throughout journey. searched open layers simple examples... couldn't more info... if has done please tell me how approach in , how it. thank guys
i have show path followed person , in map, values of lat , long present in database... have show dotted line followed person.... have integrated map passing current lat , long in static data format.... facing problem dynamic fetching ... how can show dotted line i.e path followed him...
this code-- js code-
<script> function init() { map = new openlayers.map("mapdiv"); var mapnik = new openlayers.layer.osm(); map.addlayer(mapnik); var lonlat1 = new openlayers.lonlat(77.64760799999999,12.9081357).transform( new openlayers.projection("epsg:4326"), // transform wgs 1984 new openlayers.projection("epsg:900913") // spherical mercator ); var lonlat2 = new openlayers.lonlat(78.64760799999999,11.9081357).transform( new openlayers.projection("epsg:4326"), // transform wgs 1984 new openlayers.projection("epsg:900913") // spherical mercator ); var zoom = 8; var markers = new openlayers.layer.markers( "markers" ); map.addlayer(markers); markers.addmarker(new openlayers.marker(lonlat1)); markers.addmarker(new openlayers.marker(lonlat2)); map.setcenter(lonlat2, zoom); map.setcenter(lonlat1, zoom); } </script> <body onload="init();"> <p><h3 id="h3">tracking page embeded map</h3></p> <div id="mapdiv"></div>
just me dynamically fetch multiple data database , how show on map. above code static long lat values only.. thank you.
this might you: http://wiki.openstreetmap.org/wiki/openlayers_track_example
anyway example takes data .gpx file. here keep saving coordinates in local storage:
var geolocation = new ol.geolocation({ projection: ol.proj.get('epsg:4326'), tracking: true }); geolocation.once('change:position', function() { console.log(geolocation.getposition()); $rootscope.map.getview().setcenter(geolocation.getposition()) });
with coordinates, , save them in localstorage through:
localstorage.setitem(someindex,thelocationyougot);
(remember can't store objects in localstorage, need json.stringify it!)
items localstorage, can use following:
var objeto = json.parse(window.localstorage.getitem(someindex));
and add feature layer!
greetings!
Comments
Post a Comment