Fernando
Posts: 0
Joined: Sat Mar 14, 2015 10:59 am

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

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);

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

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

Hello,

Please use .setCenter() method for that.

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

Return to “Issues”