Page 1 of 1

how to correctly show current position on google map at load page event

Posted: Thu Nov 19, 2015 12:51 pm
by Fernando

Hi,

On my load event i call a function to store gps latitude and longitude
https://getsatisfaction.com/apperyio/...

and then i show it on a google map and put a marker with current position, but when the page loads i see blue ocean... I see that latitude and longitude are correct with an alert.

i use code from this
https://devcenter.appery.io/tutorials...
and
https://getsatisfaction.com/apperyio/...

How can i make it works?

My load event code:
initGeolocation(); //save coords
var map = Appery("map").options.mapElement.gmap('get', 'map');
var markerLatLng = new google.maps.LatLng(localStorage.getItem('gpsLat'),localStorage.getItem('gpsLon'));
var marker = new google.maps.Marker({
position: markerLatLng,
map: map,
//icon: 'http://skimon.com/wp-content/uploads/...',
title: "Your Location"
});
//If old marker almost here
if(self.uniqueMarker && self.uniqueMarker.setMap)
//Delete old marker from map.
self.uniqueMarker.setMap(null);
self.uniqueMarker = marker;
google.maps.event.addListener(marker, 'click', function() {
if (confirm('Do you want to add inspection details for this property?') === true) {
Appery.navigateTo('menuInicio');
}
});
bounds.extend(markerLatLng);
map.fitBounds(bounds);


how to correctly show current position on google map at load page event

Posted: Fri Nov 20, 2015 9:48 am
by Serhii Kulibaba

Hello,

Please use .setCenter() method for that.

More information here: https://developers.google.com/maps/do...