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

Geolocation Tracking App

Joe,
It's better to leave JavaScript code in asset to be able to reuse it on different pages.

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

Geolocation Tracking App

I'll go ahead and add it to javascript1 instead. what do I put on load for "map a ride" page? what about on event click handler run javascript?

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

Geolocation Tracking App

There's this in my click event for "get directions" button. codevar sourceAddress = Tiggzi("inputSource").val();
var destinationAddress = Tiggzi("inputDestination").val();
var map = Tiggzi("directionsMap").gmap;
var panel = Tiggr("directionsPanel")[0];

displayDirections(sourceAddress, destinationAddress, map);/code and this in javascript1: code var directionDisplay;
var directionsService = new google.maps.DirectionsService();

function initialize() {
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 this on "map" page load codevar sourceAddress = Tiggzi("inputSource").val();
var destinationAddress = Tiggzi("inputDestination").val();
var map = Tiggzi("directionsMap").gmap;
var panel = Tiggr("directionsPanel")[0];

displayDirections(sourceAddress, destinationAddress, map)/code
I get this error in console: Image What do I need to add or remove and where? Thanks.

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

Geolocation Tracking App

Joe,

On Load event call the function:codeinitialize();/code

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

Geolocation Tracking App

Great news! It routes the source and destination on the map display, but it doesn't render the directions in the panel component.

Now I get an error when I click "get directions":

direction query unsuccessful response status: NOT_FOUND

When I press "show location" it populates a single two digit number with a lot of decimals, which I'm assuming is either a latitude or logintude value. How do I make it populate an address instead? And could this button javascript be causing an error that prevents the route from coming up if the input is populated in this weird non-address sort of way?

Thanks again. It's nearly working I hope!

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

Geolocation Tracking App

Hi Joe,

The message "direction query unsuccessful response status: NOT_FOUND" is displayed because Google Map didn't find route from Start to Destination. This may be if Start or Destination field is empty or if it has an incorrect value

In Geolocation service, response parameters "latitude" and "longitude" are mapped to the same text field "inputSource". That's why number is shown. If you want it to display the address you would need to use Reverse Geocoding Rest Service: https://developers.google.com/maps/do...

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

Geolocation Tracking App

I'll try to figure that out for now, but also, the directions still don't render in the panel below. Any thoughts as to what might be causing that?

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

Geolocation Tracking App

Joe,

Directions are not displayed in Panel because you call function "displayDirections" incorrectly. On "Get directions" button click you call:
codedisplayDirections(sourceAddress, destinationAddress, map);/code
There should be:
codedisplayDirections(sourceAddress, destinationAddress, map, panel);/code

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

Geolocation Tracking App

It shows the NOT_FOUND error on page load. Would that mean the error is also in page load? Or elsewhere? Also, how would I add the reverse geocoding javascript to my maps page? Obviously I wouldn't need all of the code provided in the API example, I'm just wondering where and how to add it so that it would best serve the app in case I need to use it on my "weather" or "record a ride" pages. Thanks!

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

Geolocation Tracking App

Hi, working on error you get. As for reverse geocoding this post should help https://getsatisfaction.com/tiggzi/to...

Return to “Issues”