I went through the tutorial for Google Directions Api http://devcenter.appery.io/tutorials/... and the service is not working for me. This my javascript:
try{
var directionDisplay;
var directionsService = new google.maps.DirectionsService();
function initialize123() {
directionsDisplay = new google.maps.DirectionsRenderer();
}
function displayDirections(sourceAddress, destinationAddress, map, panel) {
var request = {
origin: sourceAddress,
destination: destinationAddress,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
Code: Select all
directionsService.route(request, function(response, status) {
if (panel != null) {
directionsDisplay.setPanel(panel);
}
directionsDisplay.setMap(map);
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
} else {
alert("Directions query unsuccessful. Response status: " + status);
}
});
}
}
catch(e){
console.log(e);
}
The javascript for the button:
//=================================
var sourceAddress = $('#location_input1').val();
console.log("sourceAddress: " + sourceAddress);
var destinationAddress = Appery("event_Address").text();
console.log("destinationAddress: " + destinationAddress);
var map = Appery("directionsMap").gmap;
//var panel = Appery("directionsPanel")[0];
//====================================
var panel = Appery("panelMap")[0];
//displayDirections(sourceAddress, destinationAddress, map, panel);
try {
Code: Select all
displayDirections(sourceAddress, destinationAddress, map, panel);
} catch (e) {
Code: Select all
console.log(e);
}
On load:
initialize123();