i have page @ http://www.no1hastings.check.com.au/directions.html visitors can directions anywhere fixed point. destination google geocoder recognises street address (1 morwong drive) display name of building there (no. 1 in hastings street) google doesn't recognise.
is there way set street address destination alias building name when result displayed?
one option modify string in response before sending directionsrenderer:
function calcroute() { var request = { origin: 'brisbane qld australia australia', // origin: 'brisbane qld, australia', destination: '1 morwong drive, noosa heads qld, australia', // waypoints:[{location: 'bourke, nsw'}, {location: 'broken hill, nsw'}], travelmode: google.maps.directionstravelmode.driving, unitsystem: google.maps.unitsystem.metric }; directionsservice.route(request, function(response, status) { if (status == google.maps.directionsstatus.ok) { var route = response.routes[0]; var lastleg = route.legs[route.legs.length-1]; response.routes[0].legs[route.legs.length-1].end_address = 'no. 1 in hastings street'; directionsdisplay.setdirections(response); } else alert("directions request failed: "+status); }); }
to handle case directions changed directionsrenderer (i.e. dragging origin), (where changeend global , set false), note have undesireable results if user drags destination (you may want prevent that: google maps api v3 2 markers 1 fixed 1 dragged):
google.maps.event.addlistener(directionsdisplay, 'directions_changed', function() { computetotaldistance(directionsdisplay.directions); if (!changeend) { var response = directionsdisplay.getdirections(); var route = response.routes[0]; var lastleg = route.legs[route.legs.length-1]; response.routes[0].legs[route.legs.length-1].end_address = 'no. 1 in hastings street'; changeend = true; directionsdisplay.setdirections(response); } else changeend = false; });