KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am having trouble creating/replicating the google maps directions function. I am able to get it working fine when I have a From/To field but as soon as I try to add multiple destinations it does not work. I have looked on the we but I am not getting any really good example tutorials showing how this is done. Below is what I have done so far. But I am pretty sure this is done really badly. Any examples would be great. <linkhref=http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" /> <script src=http://maps.google.com/maps/api/js?sensor=false&key=xxxxx" type="text/javascript"></script> <script type="text/javascript"> var intTextBox = 0; //FUNCTION TO ADD TEXT BOX ELEMENT function addElement() { intTextBox = intTextBox + 1; var contentID = document.getElementById('content'); var newTBDiv = document.createElement('div'); newTBDiv.setAttribute( 'id', 'strText' + intTextBox); newTBDiv.innerHTML = "Text " + intTextBox + ": <input type='text' id='" + intTextBox + "' name='" + intTextBox + "'/>"; contentID.appendChild(newTBDiv); } //FUNCTION TO REMOVE TEXT BOX ELEMENT function removeElement() { if (intTextBox != 0) { var contentID = document.getElementById('content'); contentID.removeChild(document.getElementById( 'strText' + intTextBox)); intTextBox = intTextBox - 1; } } var address = '<%= hdnDefault.Value %>'; //Hidden field contains default city London var rendererOptions = { draggable: true }; var directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions); ; var directionsService = new google.maps.DirectionsService(); var map; var mygc = new google.maps.Geocoder(); mygc.geocode({ 'address': address }, function(results, status) { var country1 = results[0].geometry.location.lat(); var country2 = results[0].geometry.location.lng(); var australia = new google.maps.LatLng(country1, country2); initialize(australia); } ); fu
Tags (comma-separated)
Save Edits
Cancel