Skip to content
This repository has been archived by the owner on Nov 30, 2018. It is now read-only.

[question] Is it possible to show infowindow only one at a time? #186

Closed
armno opened this issue Jan 13, 2014 · 5 comments
Closed

[question] Is it possible to show infowindow only one at a time? #186

armno opened this issue Jan 13, 2014 · 5 comments
Labels

Comments

@armno
Copy link

armno commented Jan 13, 2014

Hi. I created markers and infowindows using <markers> and <windows> directives. So when I click on a marker, it shows the marker's infowindow. But when I click on another marker, I'd like it to close opened window before open a new one. So there is only 1 window opened at a time. (I'm doing a mobile web so there is not that much spaces to show many things.)

Is it possible to implement like this? I was thinking about attaching a click event to each marker and so when it's clicked, I'll close opened window first (if any) but still don't have ideas how to access to those windows and call a close function on them.

here's my code

<markers models="map.markers" coords="'self'" click="'click'">
  <windows show="true">
  <!-- window content -->
  </windows>
</markers>

and in the controller

// close opened window (if any)
var onMarkerClick = function(marker) {
  // do something
};

_.each($scope.map.markers, function(marker) {
  marker.click = onMarkerClick;
});
@nmccready
Copy link
Contributor

Yes, I actually do this myself. You can also use with markers and only show a window that is active by tracking a collection of activeMarkers. If you only want one active then only one object in your collection should allow show to be true.

@nmccready
Copy link
Contributor

Go here and search for epiphany . #83

@armno
Copy link
Author

armno commented Jan 14, 2014

thanks @nmccready! it works really well. 👍

@sanketch
Copy link

I am trying to get the same result but using window, marker and ng-repeat. How would I go on changing the following so that only one info window is shown at a time? The problem here is that I am getting coordinates from a result array and that doesn't have any extra fields for me to track whether an exisiting window attached to that is open, so my show attribute is linked to a single field in the scope which either shows all the info windows or closes them. How can I open only one at a time?

        <marker 
            ng-repeat="result in results" 
            coords="result.coords" 
            click="onMarkerClicked(result)">
                <window ng-cloak 
                    show="map.infoWindowWithCustomClass.show" 
                    isIconVisibleOnClick="true" 
                    options="map.infoWindowWithCustomClass.options">
                        <div>
                            Window Content
                        </div>
                </window>
        </marker>

@nmccready
Copy link
Contributor

#83

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants