Thanks for your reply , i try with <input type="button" value="Calculate Distance" onclick="calculateDistance();" /> and have the error "Object Expected" , this is the code to generate the "distance calculator" , Please let me now how solved this? Thanks in advanced. ,
var points = []; var polyline = null; var endMarker = null; var distance = 0; var listener = null; var start_icon = new GIcon(G_DEFAULT_ICON, 'http://maps.google.com/ mapfiles/dd-start.png'); var end_icon = new GIcon(G_DEFAULT_ICON, 'http://maps.google.com/ mapfiles/dd-end.png'); listener = GEvent.addListener(mmap, 'click', function(target, point) { if (point) { if (polyline) { updateEnd(point); mmap.removeOverlay(polyline); distance += points[points.length-1].distanceFrom(point); var result = distance; result = Math.round(result*100)/100; $("Result").innerHTML = "Distancia total: " + result + " metros"; } else { addStart(point); } points.push(point); polyline = new GPolyline(points, "#0000ff", 4); mmap.addOverlay(polyline); } }); function addStart(point) { var markerId = 'start'; var marker = new GMarker(point, { icon: start_icon }); marker.markerId = markerId; mmap.addOverlay(marker); } function updateEnd(point) { if (!endMarker) { endMarker = new GMarker(point, { icon: end_icon }); endMarker.markerId = 'end'; mmap.addOverlay(endMarker); } endMarker.setPoint(point); } function restart() { mmap.clearOverlays(); points = []; polyline = null; endMarker = null; distance = 0; $("Result").innerHTML = ""; } function $(id) { return document.getElementById(id); } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/Google-Maps-API?hl=en -~----------~----~----~----~------~----~------~--~---
