Hi, I want know how could I do the next. Through geolocation (html5), I obtain the coordinates (latitude and longitude) of one device, for example, in my city. Ok. The device moves by some streets of my city, and I'd like draw a line in the map, in order to display the route of the device...... What I understand is that I need Xapi or similar in order to do this, because only with OpenLayers I won't can do this because it's a slippy map. Correct me if I'm wrong because I'm not quite sure what I'm tell you, but is what I understand... I have a sample of how display a map on depending of some coordinates obtained by the browser, here. What steps I have to do? I imagine I need watchPosition, in order to look the position of the device continuously, and when there're changes, obtain the new position. But I don't know how connect everything...? Someone can put a sample example? Best regards. asked 05 Jul '12, 16:50 garciasanche... aseerel4c26 ♦ |
No need for xapi here. Xapi queries the osm database, but what you want is to draw stuff (using openlayers for example) on a canvas/slippymap (you could even draw it on a blank surface). Using openlayers, you want to draw a linestring object, and simply call addpoint() on it when the location changes. And indeed (although I'm no openlayers expert) it seems like the callback given to watchPosition (as in the geolocation OL example) is the right place to do so. answered 06 Jul '12, 10:51 Vincent de P... ♦ 1
Hi Vincent! Thanks very much for your help. So, I don't need xapi, I only need OpenLayers in order to draw the rute. I've one question: following your steps, will I obtain a map which will update itself automatically? Regards, Daniel
(06 Jul '12, 11:36)
garciasanche...
|