Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actions need callbacks #315

Open
riklaunim opened this issue Feb 21, 2014 · 0 comments
Open

Actions need callbacks #315

riklaunim opened this issue Feb 21, 2014 · 0 comments

Comments

@riklaunim
Copy link

Without callbacks for actions it's hard to take full use of map features. Like I wanted to highlight a result on list when infobubble is opened and de-highlight it when closed.

I've hacked the googlv3.core.js and added custom attribute for markers:

@@ -636,6 +658,8 @@ Marker: {
                this.openInfoBubble.fire( { 'marker': this } );
                infowindow.open(this.map, this.proprietary_marker);
                this.proprietary_infowindow = infowindow; // Save so we can close it later
+        var callback = marker.getAttribute('bubbleOpenedCallback');
+        callback(marker);
        },

        closeBubble: function() {
@@ -643,6 +667,8 @@ Marker: {
                        this.proprietary_infowindow.close();
                        this.proprietary_infowindow = null;
                        this.closeInfoBubble.fire( { 'marker': this } );
+            var callback = this.getAttribute('bubbleClosedCallback');
+            callback();
                }
        },

@@ -711,3 +737,4 @@ Polyline: {

It's not a generic solution, but such callbacks would be very handy in general.

Closing other infobubbles on Google v3 when another one is getting opened could also be a callback or built it (openstreetmap closes other bubbles) - mxn.googlev3.core.js release-3.0 branch:

@@ -621,6 +637,12 @@ Marker: {
        },

        openBubble: function() {
+        clearExistingInfoBubbles(this.mapstraction.markers);
+        function clearExistingInfoBubbles(markers) {
+            markers.forEach(function(marker) {
+                marker.closeBubble();
+            });
+        }
                var infowindow, marker = this;
                if (!this.hasOwnProperty('proprietary_infowindow') || this.proprietary_infowindow === null) {
                        infowindow = new google.maps.InfoWindow({

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

No branches or pull requests

1 participant