Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

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)

Joe Paisley
Posts: 0
Joined: Thu Mar 14, 2013 8:41 pm

Geolocation Tracking App

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&quot
/* Mobile Ad */
google_ad_slot = "5144076950&quot
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.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Geolocation Tracking App

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.

Joe Paisley
Posts: 0
Joined: Thu Mar 14, 2013 8:41 pm

Geolocation Tracking App

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&quot
/* Mobile Ad */
google_ad_slot = "5144076950&quot
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.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Geolocation Tracking App

Sorry, no updates yet, but we'll continue working on it and I'll let you know about the results.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Geolocation Tracking App

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

Joe Paisley
Posts: 0
Joined: Thu Mar 14, 2013 8:41 pm

Geolocation Tracking App

I've changed the button click event javascript to say the code var sourceAddress = Tiggzi("inputSource").val();
var destinationAddress = Tiggzi("inputDestination").val();/code
And it still doesn't work. I get this error still: Image

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Geolocation Tracking App

Hi, we'll take a look.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Geolocation Tracking App

To get "Get Directions" button working on page Map on Load event add the following:

codeinitialize();/code

Joe Paisley
Posts: 0
Joined: Thu Mar 14, 2013 8:41 pm

Geolocation Tracking App

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.

Return to “Issues”