Page 1 of 2

directions panel

Posted: Thu Sep 03, 2015 8:34 pm
by Asmaa AlHammadi

how canI display the direction panel that shows step-by-step directions between two places in google map?


directions panel

Posted: Fri Sep 04, 2015 8:25 am
by Serhii Kulibaba

Hello Asmaa,

Please look this topic:
http://stackoverflow.com/questions/24...

You have to change URL parameters "origin" and "destination" to yours


directions panel

Posted: Fri Sep 04, 2015 3:23 pm
by Asmaa AlHammadi

I use this java script and it only display blue line between two places

var map;
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
var bounds = new google.maps.LatLngBounds();

function initialize() {
console.log('Initializing...');
map = Apperyio("googlemap").gmap;
if (!map)
{
setDelay();
}
else
{
directionsDisplay = new google.maps.DirectionsRenderer();
}
}

function displayDirections(sourceAddress, destinationAddress, map) {
var request = {
origin: sourceAddress,
destination: destinationAddress,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
directionsDisplay.setMap(map);
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
} else {
alert("Directions query unsuccessful. Response status: " + status);
}
});
}

function setDelay()
{
setTimeout(initialize, 50);
}


directions panel

Posted: Sat Sep 05, 2015 3:32 pm
by Asmaa AlHammadi

Hi Sergiy,
I just got your point,
but for the mapping, what shall I use?
I mapped the start_location and end_location with the longitude and latitude
but it doesnt work


directions panel

Posted: Sun Sep 06, 2015 1:39 am
by Illya Stepanov

Hi Asmaa -

Please show your current mapping structure that you're using.


directions panel

Posted: Sun Sep 06, 2015 6:55 am
by Asmaa AlHammadi

My app can create a line between current location and destination. To enable that, I used this Java script from this tutorial “GoogleMapJs”

https://devcenter.appery.io/tutorials...

Also, I added a JS to the button that shows directions:
var sourceAddress = new google.maps.LatLng(Apperyio.storage.currentLat.get(), Apperyio.storage.currentLng.get());
var destinationAddress = new google.maps.LatLng(Apperyio.storage.temp.get(), Apperyio.storage.temp2.get());
displayDirections(sourceAddress, destinationAddress, map);

Both of current location and Destination location are variables that stored in the storage

Current location: currentLat, currentLng - Destination: temp, temp2
After that, I created a new RESTservice, then I put this link

http://maps.googleapis.com/maps/api/d...

And the parameters are origin and destination:
I just connected the start location with “currentlat” “currentlng” variables
And end_location with "temp” and “temp2”

http://s7.postimg.org/wyug6ic7f/Captu...


directions panel

Posted: Wed Sep 09, 2015 7:42 pm
by Serhii Kulibaba

Could you clarify what exactly doesn't work? Do you get directions? Could you show them?


directions panel

Posted: Thu Sep 10, 2015 9:43 am
by Asmaa AlHammadi

it shows a line between the two locations, but I am trying to show the exact steps, duration and distance to arrive to the destinations


directions panel

Posted: Mon Sep 14, 2015 7:30 am
by Serhii Kulibaba

Please use response parameters:
routes-legs-steps-start_location/end_location

instead of:
routes-legs-start_location/end_location


directions panel

Posted: Mon Sep 14, 2015 8:27 am
by Asmaa AlHammadi

thanks alot
but do I have to use both of before send and success or just one of them?