Page 5 of 8

Geolocation Tracking App

Posted: Fri Apr 12, 2013 6:52 pm
by Kateryna Grynko

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


Geolocation Tracking App

Posted: Fri Apr 12, 2013 6:55 pm
by Joe Paisley

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?


Geolocation Tracking App

Posted: Fri Apr 12, 2013 7:07 pm
by Joe Paisley

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.


Geolocation Tracking App

Posted: Fri Apr 12, 2013 7:14 pm
by Kateryna Grynko

Joe,

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


Geolocation Tracking App

Posted: Fri Apr 12, 2013 10:51 pm
by Joe Paisley

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!


Geolocation Tracking App

Posted: Mon Apr 15, 2013 8:49 am
by Kateryna Grynko

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...


Geolocation Tracking App

Posted: Mon Apr 15, 2013 12:10 pm
by Joe Paisley

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?


Geolocation Tracking App

Posted: Mon Apr 15, 2013 2:11 pm
by Kateryna Grynko

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


Geolocation Tracking App

Posted: Mon Apr 15, 2013 7:24 pm
by Joe Paisley

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!


Geolocation Tracking App

Posted: Mon Apr 15, 2013 8:01 pm
by Maryna Brodina

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