Page 1 of 1

How can I get directions from the address already defined in the map app to the location in the input field?

Posted: Wed Nov 20, 2013 9:45 pm
by Patrick Kelly

Basically, this is a case of basic programming memory loss. In the code below, I simply need to know how I can use the address that is already in the map (the one you define in the map settings and/or the one currently displayed on the map) instead of the information from the inputSource field. Something to the effect of var source Address = get.geocode("Address").val();

var sourceAddress = Appery("inputSource").val();
var destinationAddress = Appery("inputDestination").val();
var map = Appery("directionsMap").gmap;
displayDirections(sourceAddress, destinationAddress, map);


How can I get directions from the address already defined in the map app to the location in the input field?

Posted: Wed Nov 20, 2013 10:14 pm
by Igor

How can I get directions from the address already defined in the map app to the location in the input field?

Posted: Wed Nov 20, 2013 11:17 pm
by Patrick Kelly

Yeah, I've seen those and I have been looking through the documentation, but I am still a little rusty on my java programming classes that I took in college a couple years ago. I've just been having trouble finding out how to make it happen. Basically, I just need to know how to call the current address in the map so that I can put it into a variable when I click a button.


How can I get directions from the address already defined in the map app to the location in the input field?

Posted: Thu Nov 21, 2013 4:27 am
by Igor

If you use example from this tutorial than you need to add next steps:

  • Open directions.js;

    Add following lines:
    pre
    var route = response.routes[0];
    for (var i = 0; i < route&#46;legs&#46;length; i++) {
    localStorage&#46;setItem("startaddr", route&#46;legs&#46;start_address);
    localStorage&#46;setItem("endaddr", route&#46;legs&#46;end_address);
    }
    /pre

    after existing line:

    pre
    if (status == google&#46;maps&#46;DirectionsStatus&#46;OK) {
    directionsDisplay&#46;setDirections(response);
    /pre

  • Add event on "Get Directions" button click like on screen shot:

    Image

    This Link will be useful: https://google-developers.appspot.com...