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

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

garciasanchezdani's gravatar image

garciasanche...
55559
accept rate: 0%

edited 25 Nov '13, 15:48

aseerel4c26's gravatar image

aseerel4c26 ♦
32.6k18248554


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.

permanent link

answered 06 Jul '12, 10:51

Vincent%20de%20Phily's gravatar image

Vincent de P... ♦
17.3k18152249
accept rate: 19%

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...
Your answer
toggle preview

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:

×305
×44
×35
×12

question asked: 05 Jul '12, 16:50

question was seen: 5,827 times

last updated: 25 Nov '13, 15:48

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