0

how to capture ginfo onClose event

asked 2009-05-07 06:21:39 +0800

gmitev gravatar image gmitev
190 3

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?

delete flag offensive retag edit

19 Replies

Sort by ยป oldest newest

answered 2009-05-08 01:15:16 +0800

gmitev gravatar image gmitev
190 3

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.

link publish delete flag offensive edit

answered 2009-05-08 03:30:52 +0800

hideokidd gravatar image hideokidd
750 1 2

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>

And now I have no idea about how to disable onMapClick event when user click 'X'.

link publish delete flag offensive edit

answered 2009-05-08 06:14:57 +0800

gmitev gravatar image gmitev
190 3

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.

link publish delete flag offensive edit

answered 2009-05-11 06:29:27 +0800

hideokidd gravatar image hideokidd
750 1 2

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>

hmmmmm, maybe the gmap component needs more dicuments.

link publish delete flag offensive edit

answered 2009-05-11 07:05:28 +0800

gmitev gravatar image gmitev
190 3

that works perfectly except for the case of clicking the 'x' on ginfo - this cannot be detected still?

link publish delete flag offensive edit

answered 2009-05-12 04:14:08 +0800

hideokidd gravatar image hideokidd
750 1 2

updated 2009-05-12 04:15:26 +0800

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>

link publish delete flag offensive edit

answered 2009-05-13 03:06:28 +0800

gmitev gravatar image gmitev
190 3

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?

link publish delete flag offensive edit

answered 2009-05-13 04:02:42 +0800

hideokidd gravatar image hideokidd
750 1 2

updated 2009-05-13 04:03:03 +0800

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.

link publish delete flag offensive edit

answered 2009-05-15 02:21:43 +0800

gmitev gravatar image gmitev
190 3

I posted a feature request, however in the meantime a workaround would still be handy - do you ahve anything further to add to the solution?

link publish delete flag offensive edit

answered 2009-05-15 08:40:25 +0800

hideokidd gravatar image hideokidd
750 1 2

updated 2009-05-15 08:41:36 +0800

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>

Please try the example,
hope it helps a lot.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-05-07 06:21:39 +0800

Seen: 681 times

Last updated: May 26 '09

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More