Page 4 of 5

Setting permanent Google Maps destination while geolocation sets start point.

Posted: Fri Oct 25, 2013 1:42 pm
by laura Gómez

Sorry, I don't understand you very well.

I invoke geolocation service in my screen3.

The first

event, succes:

var map = Appery('googlemap_12');
map.options['address']='';
map.refresh();

and then I load).gmap;
displayDirections(sourceAddress,destinationAddress,map);


Setting permanent Google Maps destination while geolocation sets start point.

Posted: Fri Oct 25, 2013 1:44 pm
by laura Gómez

But I have this error:

Image


Setting permanent Google Maps destination while geolocation sets start point.

Posted: Fri Oct 25, 2013 1:45 pm
by laura Gómez

Sorry, I don't understand you very well.

I invoke geolocation service in my screen3.

The first

event, succes:

var map = Appery('googlemap_12');
map.options['address']='';
map.refresh();

and then

I load < invokeservice < geolocation.

Perfect.

And then I do:

edit mapping (screen3)

for latitude field:

localStorage.setItem('latitude',value);

for longitude field:

localStorage.setItem('longitude',value);

And then:

In the button,

event < click < run javascript

var sourceAddress = Appery("Screen3").val();
var long = localStorage.getItem('longitude');
var latit= localStorage.getItem('latitude');
var destinationAddress = new google.maps.LatLng(38.8667,-0.5167);
var map = Appery("googlemap_12").gmap;
displayDirections(sourceAddress,destinationAddress,map);


Setting permanent Google Maps destination while geolocation sets start point.

Posted: Fri Oct 25, 2013 2:00 pm
by Maryna Brodina

You must use this code prevar sourceAddress = new google&#46;maps&#46;LatLng(localStorage&#46;getItem('latitude'),localStorage&#46;getItem('longitude'));
var destinationAddress = new google&#46;maps&#46;LatLng(38&#46;8667,-0&#46;5167);
var map = Appery("googlemap_12")&#46;gmap;
displayDirections(sourceAddress,destinationAddress,map);/pre instead prevar destinationAddress = new google&#46;maps&#46;LatLng(38&#46;8667,-0&#46;5167);
var sourceAddress = new google&#46;maps&#46;LatLng(38&#46;8167,-0&#46;6167);
var map = Appery("googlemap_12")&#46;gmap;
displayDirections(sourceAddress,destinationAddress,map); /pre


Setting permanent Google Maps destination while geolocation sets start point.

Posted: Fri Oct 25, 2013 2:21 pm
by laura Gómez

ohh!!!!!!!!!!!!!!!! thanks!!!!!!!!!!!!!!!!!!!!!!!!!!


Setting permanent Google Maps destination while geolocation sets start point.

Posted: Wed Nov 13, 2013 4:50 pm
by Vicent Cortés

Hello,

I put the code in the tutorial so I locate, but it does not work. After I put the code from Google, and if that I find, but it does open the screen (load), but I would like me to locate when I click on the button. The code is as follows:

var map;

function initialize() {
var mapOptions = {
zoom: 6,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map($('div[dsid="googlemap"]').get(0), myOptions);

// Try HTML5 geolocation
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var pos = new google.maps.LatLng(position.coords.latitude,
position.coords.longitude);

Code: Select all

   var infowindow = new google.maps.InfoWindow({ 
     map: map, 
     position: pos, 
     content: 'Location found using HTML5.' 
   }); 

map.setCenter(pos);
}, function() {
handleNoGeolocation(true);
});
} else {
// Browser doesn't support Geolocation
handleNoGeolocation(false);
}
}

function handleNoGeolocation(errorFlag) {
if (errorFlag) {
var content = 'Error: The Geolocation service failed.';
} else {
var content = 'Error: Your browser doesn\'t support geolocation.';
}

var options = {
map: map,
position: new google.maps.LatLng(60, 105),
content: content
};

var infowindow = new google.maps.InfoWindow(options);
map.setCenter(options.position);
}

google.maps.event.addDomListener(window, 'load', initialize);

Once I located by pressing the button, I put another button so that when they click it calculate me the route from my position to the beginning of the route (it is always the same point). What would be the code so that I could do this?

Thanks and regards


Setting permanent Google Maps destination while geolocation sets start point.

Posted: Thu Nov 14, 2013 8:26 am
by Kateryna Grynko

Hi Vicent,

On button click, do you want to get a map for specified or current coordinates?


Setting permanent Google Maps destination while geolocation sets start point.

Posted: Fri Jan 03, 2014 7:24 pm
by Grant Smith

I've gone through this and many other resources and still can't figure out why I'm getting the following error:

link:
http://appery.io/app/mobile-frame?src... Image


Setting permanent Google Maps destination while geolocation sets start point.

Posted: Fri Jan 03, 2014 8:35 pm
by Kateryna Grynko

Hi,

Where do you get this error? What are you trying to do? Are there any console errors (F12)?


Setting permanent Google Maps destination while geolocation sets start point.

Posted: Fri Jan 03, 2014 9:22 pm
by Grant Smith

Thanks for the quick response,

I get this error on the Directions page when I click the "Use Current Location" button. This button is meant to use the GeoLocation and a specified Destination to give the user direction on a Google Map (like what this thread has been talking about). The console shows the following error:
event.returnValue is deprecated. Please use the standard event.preventDefault() instead.

Thanks!