Troy Cooper
Posts: 0
Joined: Wed Jun 05, 2013 8:39 pm

Setting permanent Google Maps destination while geolocation sets start point.

I am trying to build Google Directions into my app but I want to set the destination permanently and have the start point be set by the phones geolocation automatically. I tried modifying the code given in the tutorial under "Build a mobile app with Google Map and Google Directions API" and "Building a mobile app with Google Map and Geolocation" but it didn't work.

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

Setting permanent Google Maps destination while geolocation sets start point.

Hi Troy,

What exactly doesn't work?
Are there any errors in console?
Did you try to do the tutorial exactly?

Troy Cooper
Posts: 0
Joined: Wed Jun 05, 2013 8:39 pm

Setting permanent Google Maps destination while geolocation sets start point.

Thanks for responding so quickly.:

You asked, "What exactly doesn't work?" and "Did you try to do the tutorial exactly?"
~ By following the tutorial, "Building a mobile app with Google Map and Geolocation" I was able to use the app to find my location. However, it would get rid of the marker that was on my business. I thought that if I could get it to give directions from where ever users are then the disappeared marker wouldn't really matter.
So, I tried the other tutorial "Build a mobile app with Google Map and Google Directions API" but tried to modify the code as I went along to make the geolocation was the start point in route guidance and my business as the destination. When I tested the app, the map appeared on screen without a problem but neither the geolocation or the route guidance worked at that point.

"Are there any errors in console?"
~ I don't know quite what this means. I did not get any error messages though.

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

Setting permanent Google Maps destination while geolocation sets start point.

In Chrome / Mozilla Firefox click F12 to open Chrome developer console / Firebug.

Troy Cooper
Posts: 0
Joined: Wed Jun 05, 2013 8:39 pm

Setting permanent Google Maps destination while geolocation sets start point.

I opened the web console in Firefox and retested the app. It says "Geolocation is not defined."

Troy Cooper
Posts: 0
Joined: Wed Jun 05, 2013 8:39 pm

Setting permanent Google Maps destination while geolocation sets start point.

Closer inspection shows that it says I have an error in my javascript on line 10. This is what I have as my javascript. How should I define "geolocation"?

var directionDisplay;
var directionsService = new google.maps.DirectionsService();

function initialize() {
directionsDisplay = new google.maps.DirectionsRenderer();
}

function displayDirections(sourceAddress, destinationAddress, map) {
var request = {
origin: Geolocation,
destination: google.maps.LatLng(41.719111, -111.846469),
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
directionsDisplay.setMap(map);
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
} else {
alert("Directions query unsuccessful. Response status: " + status);
}
});
}

Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

Setting permanent Google Maps destination while geolocation sets start point.

Hello.

You should define "Geolocation" variable.
code
var Geolocation=put here some value;
/code

Troy Cooper
Posts: 0
Joined: Wed Jun 05, 2013 8:39 pm

Setting permanent Google Maps destination while geolocation sets start point.

Hey Igor,

How do I define "Geolocation" so that the mobile device the app is installed on inserts the proper value? I know pretty much nothing about programming... Sorry!

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

Setting permanent Google Maps destination while geolocation sets start point.

Hello! Could you give us your public app link?

Return to “Issues”