infoWindow when map is click-Collection of common programming errors
I just want a map that when the map is click an infoWindow appears but without a marker. Furthermore, inside the infoWindow (using reverse geocoding) the address of where the user click on the map is also displayed. I have researched and try to code it but when i click the map the infoWindow does not appear. Where could be the bug or is there another way of doing it?Any help would be appreciated. Here is the site site hosted the map;
http://urloritdidnthappen.appspot.com/186002
-
The issue is that here
infoWindow.open(map);
map
is undefined. That’s because this linevar map = new google.maps.Map(document.getElementById("map"), options);
sets
map
to be local to theinitialize()
function.Fix: remove
var
from the linevar map =...
so that it assigns a value to the global variable.
Originally posted 2013-11-09 23:34:03.