View Full Version : click, mouseover and mouseout question
comprx
07-08-2009, 07:54 AM
I am having trouble getting these three to work well together, specifically with the google maps api.
What i want:
mouseover a pin on the map and get the info window
mouseout and the info window leaves
click and it stays open even if you mouseout
Here is my code:
GEvent.addListener(marker, 'mouseover', function() {
marker.openInfoWindowHtml(html);
});
GEvent.addListener(marker, 'mouseout', function() {
marker.closeInfoWindow(html);
});
GEvent.addListener(marker, 'click', function() {
marker.openInfoWindowHtml(html);
});
ckeyrouz
07-08-2009, 08:05 AM
Add the onblur event as well:
GEvent.addListener(marker, 'blur', function() {
marker.openInfoWindowHtml(html);
});
comprx
07-08-2009, 09:16 PM
ok but that doesn't solve my problem?
If i click on them they still close when i move the mouse away.
ckeyrouz
07-08-2009, 09:38 PM
Excuse me for the misunderstanding I think it was a quick answer from my side.
So you want the mouseout event close the window if the window was opened with the event mouseover and you want the mouseout event not being able to close the popup if the latter was triggered by the click event.
inside the click event:
GEvent.addListener(marker, 'click', function()
{
marker.openInfoWindowHtml(html);
// take the id of the pin and put them in a global array or global variable
// the way you want to manage it
// I mean gather in the way you like the ids of the pins that have
// been opened by clicking upon
});
GEvent.addListener(marker, 'mouseout', function()
{
//add a condition here that this pin was not opened by click
// if it was not opened by click then close is else do nothing
// check if this id is one of the ids is gathered using the click method
marker.closeInfoWindow(html);
});
do not forget to remove the id from the gathered list once you close it manually.
I do not know how to get the if from the marker object otherwise I would have provided you with a running code.
This is why I had to explain my suggestion.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.