Loren Wolsiffer
Loren Wolsiffer

Reputation: 167

Modify the driving directions Gmaps V3

This should be simple but not for me. The displayed directions all work fine except the b point (end). The b marker displays 781-815 county road 555 but it should display 4011 Kings highway. in the following code,

    directionsDisplay.setPanel(document.getElementById('directions-panel'));

Is there any way to do a replace on 781-815 county road 555 and display the kings highway address. I have Googled everything I can think of but all I can alert is Object Object. Thanks for any help.

Upvotes: 0

Views: 658

Answers (1)

Loren Wolsiffer
Loren Wolsiffer

Reputation: 167

I figured it out. create,

    directions2Display = new google.maps.DirectionsRenderer(); 

Then added a Json lib file

    var string = JSON.stringify(response); 
    var newString = string.replace("Turn", "Drive"); // replace what you need here
    myDirections = JSON.parse(newString); 
    directions2Display.setDirections(myDirections);
    directions2Display.setPanel(document.getElementById('directions-panel')); 

No errors and works a treat. –

Upvotes: 1

Related Questions