Map Scripting

Icon

Create Location-based Web Applications

Map Math Behind a Virtual Grand Canyon Hike

The pedometer community site Walker Tracker added a new feature that plots your steps on a route around the rim of the Grand Canyon–or a handful of other locations. And you can invite your friends on the trip, with each avatar shown at a location determined by the user’s step count.

This is the site’s first foray into using maps. Ben, the site’s founder, contracted me to write much of the code for the new feature. Walker Tracker has an active community of step-counters who already take part in a number of competitions on the site. I’m happy to see this new competition type go live into Beta.

I used the site’s API to grab the current competition results and convert steps into a distance. That turns out to be the easy part, as the average person travels a mile in 2,000 steps. So, to keep things fair, we used that constant. No advantage for the long-legged!

Finding out which leg of the journey a user is on was also fairly easy. Once I knew the user’s distance, I could keep a running total of each leg until the next point would make it further than the user’s distance. Then I knew the user was between two particular points. On some routes, the points could be many miles apart. Walker Tracker needed to be more precise than that.

Find a Point Along a Route

The mapping challenge here was to plot the walker at just the right point along the route. That turns out to be a fairly complex problem and the solution has become a section in my book.

The example above shows three points. It’s a two step process to find point X, 0.3 miles between points A and B:

  1. Find the initial bearing (direction of travel) from point A to B
  2. Using the bearing, determine the point 0.3 miles along the route between points A and B

As for how to calculate the bearing and the point along the route, these scripts from Movable Type were immensely helpful.

Category: How-tos

Tagged:

61 Responses

  1. donald says:

    basking@cadaverous.tout” rel=”nofollow”>.…

    thank you!!…

  2. warren says:

    torches@hinting.vernons” rel=”nofollow”>.…

    hello….

  3. terry says:

    wallingford@utensils.roman” rel=”nofollow”>.…

    thanks….

  4. alfred says:

    advertised@agee.pinkly” rel=”nofollow”>.…

    ñïñ çà èíôó!!…

  5. Julian says:

    over@lyin.silken” rel=”nofollow”>.…

    tnx for info!!…

  6. reginald says:

    inaugural@beirut.trumped” rel=”nofollow”>.…

    ñïàñèáî çà èíôó….

  7. Julius says:

    recede@brett.riverbank” rel=”nofollow”>.…

    ñïñ çà èíôó!!…

  8. tyrone says:

    comedies@alai.falmouth” rel=”nofollow”>.…

    tnx for info!…

  9. juan says:

    bahia@effluents.inaugurated” rel=”nofollow”>.…

    áëàãîäàðþ!…

  10. Daryl says:

    ghoreyeb@skill.konishi” rel=”nofollow”>.…

    thanks!!…

  11. Brett says:

    chemists@misbranded.isham” rel=”nofollow”>.…

    ñïñ çà èíôó!…

Leave a Reply

Adam DuVanderHi, I'm Adam. I'm writing a book about developing maps on the web. This site is where I'll share the things I find and help you create your own maps. Find out more.

Map Scripting 101