0

Say I have a Google maps v2 GMarker like this:

var marker = new GMarker(point, {
  icon :myicon,
  title :'whatever'
});
GEvent.addListener(marker, "mouseover", function() {
  myover(pointid);
});
GEvent.addListener(marker, "mouseout", function() {
  myout(pointid);
});

I would like behavior similar to jquery - hoverintent instead of the normal mouseover and mouseout events, to avoid hyperactivity when moving the mouse across the screen and accidentally touching a GMarker. I would like my functions to be triggered only when the mouse slows down or stops at a marker. This can be solved using hoverintent for normal dom-elements such as table rows (tr).

My problem is, I do not know how to select a GMarker using jQuery. If it cannot be done, how do I hook my GMarkers into hoverintent in some other way?

Thanks,

tomsv
  • 7,207
  • 6
  • 55
  • 88

1 Answers1

1

I kind of solved this by rolling my own based on this answer: Delay jquery hover event?

This only gives the delay without the slow moving mouse cursor, but it is enough for now.

This is what it turned out:

GEvent.addListener(marker, "mouseover", function() {
  if (this.timer) {
    clearTimeout(this.timer);
    this.timer = null;
  }
  this.timer = setTimeout(function() {
    myover(pointid);
  }, 100);
});
GEvent.addListener(marker, "mouseout", function() {
  if (this.timer) {
    clearTimeout(this.timer);
    this.timer = null;
  }
  myout(pointid);
});
Community
  • 1
  • 1
tomsv
  • 7,207
  • 6
  • 55
  • 88