Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add showInfowindow method to Markers #306

Closed
excid3 opened this Issue · 3 comments

2 participants

Chris Oliver Benjamin Roth
Chris Oliver

I wanted to propose adding a method like this to the Marker classes:

  showInfowindow : () ->
    @controller._closeVisibleInfoWindow()
    @infowindow.open(@getMap(), @serviceObject)
    @controller._setVisibleInfoWindow @infowindow

We've got this method:

  _openInfowindow : () ->
    that = @
    return ->
      # Close the latest selected marker before opening the current one.
      that.controller._closeVisibleInfoWindow()
      that.infowindow.open(that.getMap(), that.serviceObject)
      that.controller._setVisibleInfoWindow that.infowindow

Which is very similar and wondered what your thoughts were on adding something like this. It makes it really easy for me to add a "View on Map" link that I can use a data attribute to quickly find the marker and show the infowindow like so:

  $('.marker-link').on 'click', ->
    id = $(this).data("marker-id")
    marker = $.grep Gmaps.map.markers, (e) ->
      e.id is id
    marker[0].showInfowindow()

Figured this might be useful, but wanted to get some feedback before I submitted a pull request.

Benjamin Roth
Owner

what about:

showInfowindow : () ->
   (@_openInfowindow())()
Chris Oliver

Yes if that works! (I'm not great at javascript yet). Just mainly wanted a simpler way to find and show the infowindow from javascript.

Chris Oliver

I'm revisiting this pretty late, but I can confirm that your code does work for me. (and it's a lot simpler :smile:)

I can submit a pull request for this on just Google Maps, but I'm not familiar with how to do this on OpenLayers or Bing maps since I've never used them. I imagine it'd be useful to have on each, so do you know which docs to point me to and I'll see about adding this for the other providers?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.