Rahul Chidgopkar
Posts: 0
Joined: Tue May 14, 2013 7:11 am

How to set marker on google map on page load?

Hi,

I need to set a marker on googlemap using lat long stored in local variables. This is my code:
var lat = parseFloat(localStorage.getItem('latitude'));
var long = parseFloat(localStorage.getItem('longitude'));
var map = new google.maps.Map($('div[dsid="googlemap"]').get(0), {
zoom: 11,
center: new google.maps.LatLng(lat,long),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var marker = new google.maps.Marker({
position: new google.maps.LatLng(lat,long),
map: map
});

Max had suggested a Full Page Refresh as a possible solution in this thread - https://getsatisfaction.com/apperyio/...

When I do that, it works for a couple of seconds and the map gets reset.

The same code works fine if I put it in a Button click event on the page. I think this has something to do with page and map loading being asynchronous, but I'm not sure. Please help me out.

Thanks,
Rahul.

Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

How to set marker on google map on page load?

Hi Rahul,

Do you have any other events on Page load?
Look in the console if there is an error?

On the next tutorial you can find how to use browser console
http://docs.appery.io/documentation/a...

Return to “Issues”