-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I am able to catch the onMapClick event when I click on a gmap, however this event will also fire when I click the 'x' on the ginfo bubble - I wish to distinguish between gmap click and ginfo click.
How can I get the onClose event (if there is such a thing) when I click on the 'x' of a ginfo bubble?
Actually what i really want is, when I click on the ginfo bubble/'x' for my onMapClick event to not get called.
It seems because the ginfo lies within the map bounds any click within the map including the ginfo will trigger this event.
So i need to say, if click on ginfo, do nothing or just close.
Hi,
The question may be a bug,
but now I have no idea about how to solve it,
just provide a possible workaround,
The code is revised from zk demo,
I just check whether user click on map or a gmarker.
<attribute name="onMapClick"> Gmarker gmarker = event.getGmarker(); if (gmarker != null) { //you click on map gmarker.setOpen(true); } else{ //you click on a gmarker } </attribute>
thanks that works great for gmarker, i am now able to click on gmarker and get my ginfo up.
i am also unsure how to detect click on ginfo, its almost as if we need a Ginfo ginfo = ((MapClickEvent) event).getGinfo(); method to detect that we have clicked on ginfo.
HI,
It's hard to find a event for ginfo,
so I revise my previous code to make another workaround for ginfo:
<attribute name="onMapClick"> Ginfo ginfo = self.getInfo(); Gmarker gmarker = event.getGmarker(); if (gmarker != null) { //you click on map gmarker.setOpen(true); } else if (ginfo != null){ //you click on a ginfo } else{ //you click on a gmarker } </attribute>
Hi,
Still a workaround,
I declare a variable first to store the open status of ginfo,
the default value is true;
<zscript> boolean isGinfoOpen=true; </zscript> <gmaps id="map" width="500px" height="300px"> <attribute name="onMapClick"> Ginfo ginfo = self.getInfo(); Gmarker gmarker = event.getGmarker(); if (gmarker != null) { //you click on gmarker gmarker.setOpen(true); } else if (ginfo != null){ //you click on a ginfo isGinfoOpen = true; } else{ //you click on a gmaps if (isGinfoOpen){ //you close a ginfo isGinfoOpen = false; } } </attribute> </gmaps>
my problem here is when I do:-
Ginfo ginfo = gmap.getInfo();
It is null, when I press on 'x', thereby the above code will not work for me. I am using MapModelList to add my markers and polygons etc, this makes it easier to clear the items.
I dont know if I should wait for a bug fix or continue with workarounds?
Hi,
Urrrrrr, shall we continue develop the workaround?
Since workaround may fail if new zk google map is released,
post your problem to zk bugs or zk features is better.
Hi,
The onInfoChange event may help,
first I declared a variable to store the default opened ginfo,
and the other variable to store the current active(opened) ginfo.
<zscript> Ginfo defaultGinfo = .... Ginfo currentGinfo = defaultGinfo; </zscript>
Then the onInfoChange will be
<gmaps id="map" width="500px" height="300px"> <attribute name="onInfoChange"> //fired when a ginfo is closed if (self.getInfo() == null){ //you close a ginfo and no other ginfo is opened //the closed ginfo would be currentGinfo } else{ //you close a ginfo and another ginfo is opened currentGinfo = self.getInfo(); } </attribute> </gmaps>
Asked: 2009-05-07 06:21:39 +0800
Seen: 681 times
Last updated: May 26 '09