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.