Geolocation Tracking App
You call method route, but the object is not defined. The error occurs because you didn't initialize variables with your function initialize (you don't call this function)
Catch up wih the Appery.io community on our forum. Here you'll find information on the lastest questions and issues Appery.io developers are discussing.
https://forum.appery.io/
You call method route, but the object is not defined. The error occurs because you didn't initialize variables with your function initialize (you don't call this function)
I'm sorry I don't understand. I thought I did. This is on my javascript page:
codevar bikeLayer, directionDisplay, directionsService;
function initialize() {
bikeLayer = new google.maps.BicyclingLayer('directionsMap');
bikeLayer.setMap(Tiggzi('directionsMap').gmap);
directionDisplay;
directionsService = new google.maps.DirectionsService();
directionsDisplay = new google.maps.DirectionsRenderer();
}
function displayDirections(sourceAddress, destinationAddress, map, panel) {
var request = {
origin: sourceAddress,
destination: destinationAddress,
travelMode: google.maps.DirectionsTravelMode.BICYCLING,
avoidHighways: true
};
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);
}
});
}
google_ad_client = "ca-pub-8264282481974683"
/* Mobile Ad */
google_ad_slot = "5144076950"
google_ad_width = 320;
google_ad_height = 50;/code
with this :
codeinitialize();/code
and this on load:
code var bikeLayer, directionDisplay, directionsService, directionsDisplay;
function initialize() {
bikeLayer = new google.maps.BicyclingLayer('directionsMap');
bikeLayer.setMap(Tiggzi('directionsMap').gmap);
directionDisplay;
directionsService = new google.maps.DirectionsService();
directionsDisplay = new google.maps.DirectionsRenderer();
} /code
And this on click event for the "Get Directions" button:
code
var sourceAddress = Tiggzi("inputSource").val(null);
var destinationAddress = Tiggzi("inputDestination").val(null);
var map = Tiggzi("directionsMap").gmap;
displayDirections(sourceAddress, destinationAddress, map);
/code
I tried to follow this tutorial as best as I could: http://docs.tiggzi.com/tutorials/buil...
Where did I go wrong? Thanks for the help.
Hi Joe,
Sorry for the delay. There is an error in JS:
You use two variables: directionDisplay и directionsDisplay (litter 's' differs).
You have an extra line:
codedirectionDisplay;/codeYou can delete it.
On "Map" page there is Run JavaScript action where you duplicate function initialize(). You shouldn't do that because initialize() function is defined in JS asset.
As it stands now, my javascript1 reads:
codevar bikeLayer, directionsDisplay, directionsService;
function initialize() {
bikeLayer = new google.maps.BicyclingLayer('directionsMap');
bikeLayer.setMap(Tiggzi('directionsMap').gmap);
directionsService = new google.maps.DirectionsService();
directionsDisplay = new google.maps.DirectionsRenderer();
}
function displayDirections(sourceAddress, destinationAddress, map, panel) {
var request = {
origin: sourceAddress,
destination: destinationAddress,
travelMode: google.maps.DirectionsTravelMode.BICYCLING,
avoidHighways: true
};
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);
}
});
}
google_ad_client = "ca-pub-8264282481974683"
/* Mobile Ad */
google_ad_slot = "5144076950"
google_ad_width = 320;
google_ad_height = 50;/code
And I removed the initialize () function from the "events" on the page as it is in "javascript1." All that happens now is the source and destination disappear, but no map route is rendered, nor is there a route turn-by-turn list.
Sorry, no updates yet, but we'll continue working on it and I'll let you know about the results.
Hi Joe,
To make Get Directions button display the route on map you would need to correct Run JavaScript action added to this button.
In the following lines there is an extra "null":
codevar sourceAddress = Tiggzi("inputSource").val(null);
var destinationAddress = Tiggzi("inputDestination").val(null);/code
There should be:
codevar sourceAddress = Tiggzi("inputSource").val();
var destinationAddress = Tiggzi("inputDestination").val();/code
Hi, we'll take a look.
To get "Get Directions" button working on page Map on Load event add the following:
codeinitialize();/code
Now that I've done that, the page has a lot of trouble loading. Also, on the "website" page the "map ride" button doesn't work sometimes.