I have 2 pages:
MainPage & Screen1
MainPage has Geolocation, it stores latitude & longitude to local variable, Geolocation being executed in Page_Load event
and in Geolocation success event, I call showCurrentPosition()
Screen1 has Google Map, initMap_FP being executed in Page_Load event,
so the point is:
Geolocation is on MainPage and the Google Map is on Screen1..
I have codes below..
but it does not work .. with the following error:
setCenter -- is unknown method..
My javascript1.js:
var gmap_fp;
var marker_fp;
function setDelay() {
setTimeout(initMap_FP, 50);
}
function initMap_FP() {
try
{
gmap_fp = Apperyio('gmap_fp').gmap;
if(!gmap_fp) {
setDelay();
}
} catch (err)
{alert(err);}
}
function showCurrentPosition()
{
try
{
if (gmap_fp)
{
var markerLatLng = new google.maps.LatLng(localStorage.getItem('latitude'), localStorage.getItem('longitude'));
Code: Select all
marker_fp = new google.maps.Marker({
position: markerLatLng,
map: gmap_fp,
});
marker_fp.setPosition(markerLatLng);
gmap_fp.setCenter(markerLatLng); ------- THE ERROR GOES HERE
gmap_fp.setZoom(17);
}
} catch (err) { alert(err); }
}