flask-extensions / Flask-GoogleMaps

Easy way to add GoogleMaps to Flask applications. maintainer: @getcake
https://flask-googlemaps.com
MIT License
647 stars 196 forks source link

Infobox hover and persist on click #31

Open rochacbruno opened 8 years ago

rochacbruno commented 8 years ago

Add option to show infobox on hover and persist on click.

Example

                    if (item["infobox"]) {
                        (function(_infobox, _map, _marker){
                            _marker.infoWindow = new google.maps.InfoWindow({
                                content: _infobox
                            });
                            _marker.addListener('click', function() {
                                _marker.infoWindow.open(_map, _marker);
                                _marker["persist"] = true;
                            });
                            google.maps.event.addListener(_marker.infoWindow,'closeclick',function(){
                               _marker["persist"] = null;
                            });
                            _marker.addListener('mouseover', function() {
                                _marker.infoWindow.open(_map, _marker);
                            });
                            _marker.addListener('mouseout', function() {
                                if (!_marker["persist"]) {
                                    _marker.infoWindow.close();
                                }
                            });
                        })(item["infobox"], map, marker);
                    }