On Feb 19, 12:14 pm, Richard Sámela <[email protected]> wrote:
> I'm sorry I've tried this code but it doesn't work correctly.
> I tried close my InfoWindow and it closed. but it seems like a event
> that I close the window doesn't call function onClosefn. body of the
> this function is calling the InfoWindow.
> I confess that I don't know where's a mistake.
Several errors:
There are problems with scope. Currently your function onClosefn is
defined inside your function initialize. Once intialize has finished,
everything local to it is destroyed, including your function
onClosefn. Move that function outside anything else. Variables "map"
and "myHTML" are also defined as local to function initialize, so they
get destroyed too and won't be available to other functions. Declare
those in global scope (outside anything else) and remove the "var"
keyword where you currently declare them.
Lastly, the openInfoWindow option is onCloseFn: not onClosefn. As your
function is called "onClosefn", the line should look like
map.openInfoWindowHtml( map.getCenter(), myHTML,
{ onCloseFn:onClosefn , noCloseOnClick:true } );
Once all that works, you will find that using map.getCenter() is not
really what you want to use, because if the map is moved, the
infoWindow will not reopen in the right place. Define
var centerPoint = new GLatLng(...,...)
in global scope, and use that whenever you need to specify the point
in your code.
--
You received this message because you are subscribed to the Google Groups
"Google Maps API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-api?hl=en.