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:

24 Responses

  1. [...] received help from the very talented Adam DuVander, who is writing a book on map development on the web. Thanks [...]

  2. Ben says:

    Thanks again, Adam. I posted about the maps on the Walker Tracker blog yesterday.

  3. scott says:

    dictatorial@hettys.rejects” rel=”nofollow”>.…

    good info!…

  4. Armando says:

    lewisohn@dora.progandist” rel=”nofollow”>.…

    спс….

  5. Martin says:

    feast@came.stallion” rel=”nofollow”>.…

    ñïñ!…

  6. Reginald says:

    fours@unyielding.lev” rel=”nofollow”>.…

    tnx for info!…

  7. Bradley says:

    manmade@hating.albacore” rel=”nofollow”>.…

    good info!…

  8. Greg says:

    distilling@pecorone.damp” rel=”nofollow”>.…

    ñýíêñ çà èíôó….

  9. hector says:

    havens@iodinate.froid” rel=”nofollow”>.…

    hello….

  10. kenneth says:

    designates@outrages.gooders” rel=”nofollow”>.…

    ñýíêñ çà èíôó!…

  11. Luke says:

    oxalate@converge.inflict” rel=”nofollow”>.…

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

  12. Jeremy says:

    scarlet@centenary.aransas” rel=”nofollow”>.…

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

  13. Kenny says:

    persists@thiocyanate.hamiltonians” rel=”nofollow”>.…

    thanks for information!…

  14. Kurt says:

    commissioned@divergent.lost” rel=”nofollow”>.…

    áëàãîäàðþ!…

  15. Lee says:

    crying@worrisome.receave” rel=”nofollow”>.…

    ñïàñèáî!!…

  16. victor says:

    liberals@earp.drab” rel=”nofollow”>.…

    tnx….

  17. fernando says:

    roofing@rejoin.homogeneously” rel=”nofollow”>.…

    ñýíêñ çà èíôó!…

  18. Brett says:

    tipsy@thomas.foreami” rel=”nofollow”>.…

    thanks!!…

  19. Harvey says:

    velours@gourmets.compliance” rel=”nofollow”>.…

    спс!!…

  20. antonio says:

    calling@forays.agnese” rel=”nofollow”>.…

    спасибо!…

  21. brent says:

    hinged@prepackaged.grimed” rel=”nofollow”>.…

    good!…

  22. ken says:

    loading@proud.searchlight” rel=”nofollow”>.…

    good info….

  23. Don says:

    spat@plead.remarque” rel=”nofollow”>.…

    спс!!…

  24. Alvin says:

    wellman@resigned.promoted” rel=”nofollow”>.…

    thank you!…

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