jawj / OverlappingMarkerSpiderfier

Deals with overlapping markers in Google Maps JS API v3, Google Earth-style
http://blog.mackerron.com
838 stars 238 forks source link

click trigger event #91

Open bartmoons opened 9 years ago

bartmoons commented 9 years ago

I tried multiple things to trigger a click on a marker, but it doesn't seem to work. What I want to achieve is to auto click the first marker on initialisation, so the first infowindow is open. I don't get an error message, so I think the syntax is correct.

oms.trigger(oms.a[0], 'click');
joezen777 commented 8 years ago

I looked at the coffeescript file and it's using the google event listeners. So right now I'm doing something like this on my google map drag event. Though I need to work out the kinks to have my crosshairs which is centered on my map to move slowly instead of jerky.

 map.addListener('drag',function(){
that.currentPositionMarker().setPosition({lat: that.map().center.lat(), lng: that.map().center.lng()});
      var nearbyMarker = oms.markersNearMarker(that.currentPositionMarker(),true);
      //console.log('nearbyMarker');
      //console.log(nearbyMarker);
      if ((nearbyMarker || []).length){
        google.maps.event.trigger(nearbyMarker[0],'click');
      }
}