Click to See Complete Forum and Search --> : Measuring distance on line


Thabani
10-02-2003, 12:55 AM
People is there anybody who has worked with maps. I need to measure a street distance on a web map using javascript (this web map is like an image - so all clicks are like image clicks). The problem is I can measure from two points (straight line with two ends) but when it comes to street lines with more that one segments I'm batling. I know it can be done probably using mouse events (one first mouse click, on mouse move, on mouse click and on mouse double click). The problem is more complicated by the fact that the map has other image buttons of which tells the web map what to happen to it: one of those buttons images is the measure distance button. Others are zoom in button(working), zoom out (working) and pan button(working).

Gollum
10-02-2003, 02:14 AM
What are you trying to do?
- Get the user to trace their path on the map and follow the mouse moves?
or take the user's start and end points and work out the distance somehow?

The first option isn't too hard, you just catch the onmousemove event and compare the last x,y position with the current one and add that to a running total.

The second is more complicated. Javascript cannot interpret images in any way, you will need to provide geometric data about the streets in addition to the image to be able to work out the distances.

Thabani
10-02-2003, 07:29 AM
Thank you
Gollum

Actualy "your" first question is more like it. I was just cought in the mist of trying to explain it. Okay, I think I got it. basically create a point object and the use the push/pop() to all your coordinates into an array. that way you can not only get the total distance at once but also get tot draw a line for ur route and still have all ur source data in an array.

Thanx a lot.