2fas2c
Posts: 0
Joined: Mon Dec 16, 2013 11:43 pm

Unable to put a marker based on an address into the Map

I have an address field on a page. On the same page, I have a button "Map Location". On click of the button, I set the address into a localStorage variable and then launch another page (MapLocation) which has the Map component. On page load of MapLocation, I have the following code:

var fulladdress = localStorage.getItem("fulladdress");
var map = Appery("map");
map.options["address"] = fulladdress;
map.refresh();

The map gets displayed but the address is not marked. I do get an error/warning in the Firebug that the map is not initialized.

If I add a button on MapLocation page and execute the same code on button click, everything works fine. The marker is added in the right location and it also zooms to the right level.

How can I get it to work on load instead of button click?

Thanks

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

Unable to put a marker based on an address into the Map

Hello,

Lets try to add initialize() function on page load event :
http://docs.appery.io/tutorials/build...
https://developers.google.com/maps/do...

2fas2c
Posts: 0
Joined: Mon Dec 16, 2013 11:43 pm

Unable to put a marker based on an address into the Map

I am sorry but are you asking me to move the code that I have into an initialize() method and associate the initialize() method to window load using

google.maps.event.addDomListener(window, 'load', initialize);

in the page Load event?

function initialize() {
var fulladdress = localStorage.getItem("fulladdress");
var map = Appery("map");
map.options["address"] = fulladdress;
map.refresh();
}

Return to “Issues”