django - Itinerary Not rendered With directionsDisplay.setDirections(result) in Javascript -
i try render itinerary in javascript using variable django model. can render single location itinerary... doesn't work... basicaly use geocode function convert input address geometry location when use these coordinates doesn't show anything...
here code, if can me great!
<script> var directionsdisplay; var directionsservice = new google.maps.directionsservice(); var map; function initmap() { directionsdisplay = new google.maps.directionsrenderer(); var mapoptions = { zoom:12, center: {lat: 0, lng: 0}, maptypeid: google.maps.maptypeid.roadmap } map = new google.maps.map(document.getelementbyid('map'), mapoptions); directionsdisplay.setmap(map); var geostart = new google.maps.geocoder(); var startpos; var start = document.getelementbyid('addrloc').value; geostart.geocode({'address': start}, function(results, status) { if (status === 'ok') { startpos = results[0].geometry.location; } else { alert('address has not been found'); } }); var geoend = new google.maps.geocoder(); var endpos; var end = document.getelementbyid('addrdest').value; geoend.geocode({'address': end}, function(results, status) { if (status === 'ok') { endpos = results[0].geometry.location; } else { alert('address has not been found'); } }); var request = { origin: startpos, destination: endpos, travelmode: 'driving' }; directionsservice.route(request, function(result, status) { if (status == 'ok') { directionsdisplay.setdirections(result); } }); } </script>
Comments
Post a Comment