<<"Pics from Mike's Bike Trip" [Main Index] "Sun Ray Deployment at IS195">>
Running Route Database - Update17 August 2005
Been making some improvements to my Running Route Database. - Reverse Geocoding now works again - When drawing a new route, it displays the current distance as you draw the map (a la gmapPedometer) - Simple query engine to search by Country, state, length and bike/run - Highlight of 5 most recent routes On the drawing board is: - Comments / route ratings - Undo button while creating maps
Replies: 1 Comment
Hi David,
I've used some of your code on my page: http://simon.nuttall.name/bicycles/journey/draw.route.html
and I've added and undo button. The code for which is below.
I'd be interested to know how you process the code for the defined route. - I would like to be able to add routes to my database.
cheers,
Simon
HTML:
Undo last line
Javascript:
var points = []; var lines = []; var distances = []; distances.push(0); var total_distance = 0;
// also I've defined maglob to point to the google map.
GEvent.addListener(map, "click", function(overlay, point) ( if (points.length == 0) ( map.addOverlay(new GMarker(point)); ) if (point.x != "")( points.push(point); var line = new GPolyline(points.slice(points.length-2,points.length),"#0000ff",3,0.5); lines.push(line); map.addOverlay(line); if (points.length > 1) ( total_distance += distance_between_points( points[points.length-2], points[points.length-1] ); distances.push(total_distance); displayDistance(total_distance); ) ) ) );
function displayDistance(distance) ( var theParagraph = document.getElementById('routelength'); theParagraph.firstChild.nodeValue = "Route Length: "+Math.round(distance*10*0.621371192)/10+" miles ("+Math.round(distance*10)/10+"km)"; )
function undolastline() ( if (points.length > 1) ( // remove line points.pop(); mapglob.removeOverlay(lines.pop()); distances.pop(); total_distance = distances[distances.length-1]; displayDistance(total_distance); ) else ( // remove start marker points.pop(); mapglob.clearOverlays(); total_distance = 0; displayDistance(total_distance); ) )
Simon Nuttall said @ 10/14/2005 01:16 AM EST
|