Page 1 of 1

GPS function google maps

Posted: Tue Apr 08, 2014 5:59 pm
by Lars Holtet

Hi!

I have looked at your new google map tutorials, you can type in directions "from" and "to".

Is these tutorials- i wonder if the function also is so you just can type in the "to" field- and use it as a gps from your current location without filling out the "from" input field?

I also wonder if it is any easy way to get your gps grid viewable?


GPS function google maps

Posted: Tue Apr 08, 2014 6:18 pm
by Kateryna Grynko

GPS function google maps

Posted: Wed Apr 09, 2014 12:51 pm
by Lars Holtet

Thanks :)

I have built the second link you got. The only field i miss there is a destination input field- wich i can travel from "my location"... None of the tutorials seem to mention this. Got any suggestion how to make this?


GPS function google maps

Posted: Wed Apr 09, 2014 1:41 pm
by Maryna Brodina

Hello!
Sorry, could you clarify in more details what do you mean?


GPS function google maps

Posted: Wed Apr 09, 2014 2:03 pm
by Lars Holtet

I did this tutorial. http://docs.appery.io/tutorials/build...

But what im after, is a function that i can write a "destination", and use the current gps position as "from". Bascially a normal GPS route option :)


GPS function google maps

Posted: Wed Apr 09, 2014 5:20 pm
by Kateryna Grynko

Hi Lars,

Sorry, not sure we understand. Could you provide the exact steps please?


GPS function google maps

Posted: Wed Apr 09, 2014 7:24 pm
by Alex GG

I guess he is trying to achive same approach that I looking for..
https://getsatisfaction.com/apperyio/...


GPS function google maps

Posted: Wed Apr 09, 2014 9:29 pm
by Alena Prykhodko

Hello,

Please tell us what exactly have you tried and what doesn't work.


GPS function google maps

Posted: Sun Apr 13, 2014 8:53 pm
by Lars Holtet

Hi!

Well, what i basically want is a input field that i can type in an adress/destination- so it can be used as a car gps :)


GPS function google maps

Posted: Mon Apr 14, 2014 3:03 am
by Illya Stepanov

Hello Lars,

Yes, you can create route from gps to the destination.

For this goal please follow these steps:
ol
liYou need to store latitude and longitude into LSV with names: "originLatitude" and "originLongitude".

/liliReplace js asset from tutorial with following one: http://prntscr.com/39t4bu/direct
precode
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();

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

function displayDirections(sourceAddress, destinationAddress, map) {
var coordinatesOrigin = localStorage.getItem("originLatitude") + "," + localStorage.getItem("originLongitude");

Code: Select all

 console.log("origin coordinates = " + coordinatesOrigin); 

 var request = { 
     origin: coordinatesOrigin, 
     //origin: sourceAddress, 
     destination: destinationAddress, 
     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); 
   } 
 }); 

}/code/pre/li
Note: when you run "Get directories" functional you should see in your browser console something like this: "origin coordinates = 51.3030,0.0732" if coordinates are wrong - please check out first step.

That's all. All other tutorial things you should leave without changes.

Regards./ol