Jeroen De Dauw has submitted this change and it was merged.

Change subject: Added automatic rezoom when searching for markers.
......................................................................


Added automatic rezoom when searching for markers.

Whenever a search query is entered the map will rezoom so that
all visible markers is displayed in the viewport.

Change-Id: I446f9c473fa6226a2fd3dd3e05c4f9289fb48c05
---
M includes/services/GoogleMaps3/jquery.googlemap.js
1 file changed, 28 insertions(+), 12 deletions(-)

Approvals:
  Jeroen De Dauw: Verified; Looks good to me, approved



diff --git a/includes/services/GoogleMaps3/jquery.googlemap.js 
b/includes/services/GoogleMaps3/jquery.googlemap.js
index e02b3ef..909ad4c 100644
--- a/includes/services/GoogleMaps3/jquery.googlemap.js
+++ b/includes/services/GoogleMaps3/jquery.googlemap.js
@@ -434,6 +434,18 @@
                        this.polygon = [];
                };
 
+               //Rezoom's the map to show all visible markers.
+               this.reZoom = function(){
+                       var bounds = new google.maps.LatLngBounds();
+                       for(var x = 0; x < this.markers.length; x++){
+                               var marker = this.markers[x];
+                               if (marker.getVisible() === true) {
+                                       bounds.extend(marker.getPosition());
+                               }
+                       }
+                       this.map.fitBounds(bounds);
+               }
+
                this.setup = function () {
 
                        var showEarth = $.inArray('earth', options.types) !== 
-1;
@@ -681,6 +693,8 @@
                                );
                        }
 
+
+
                        if (options.searchmarkers) {
                                var searchBoxValue = 
mediaWiki.msg('maps-searchmarkers-text');
                                var searchBox = $('<input type="text" value="' 
+ searchBoxValue + '" />');
@@ -698,25 +712,27 @@
 
                                searchBox.on('keyup',function (e) {
                                        for (var i = 0; i < 
_this.markers.length; i++) {
-                                                       var haystack = '';
-                                                       var marker = 
_this.markers[i];
-                                                       if 
(options.searchmarkers == 'title') {
-                                                               haystack = 
marker.title;
-                                                       } else if 
(options.searchmarkers == 'all') {
-                                                               haystack = 
marker.title + marker.text;
-                                                       }
-
-                                                       
marker.setVisible(haystack.toLowerCase().indexOf(e.target.value.toLowerCase()) 
!= -1);
+                                               var haystack = '';
+                                               var marker = _this.markers[i];
+                                               if (options.searchmarkers == 
'title') {
+                                                       haystack = marker.title;
+                                               } else if 
(options.searchmarkers == 'all') {
+                                                       haystack = marker.title 
+ marker.text;
                                                }
-                                       }).on('focusin', function () {
+
+                                               var visible = 
haystack.toLowerCase().indexOf(e.target.value.toLowerCase()) != -1;
+                                               marker.setVisible(visible);
+                                       }
+                                       _this.reZoom();
+                               }).on('focusin',function () {
                                                if ($(this).val() === 
searchBoxValue) {
                                                        $(this).val('');
                                                }
-                                       }).on('focusout', function () {
+                               }).on('focusout', function () {
                                                if ($(this).val() === '') {
                                                        
$(this).val(searchBoxValue);
                                                }
-                                       });
+                               });
                        }
 
                        if(options.imageoverlays){

-- 
To view, visit https://gerrit.wikimedia.org/r/101828
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I446f9c473fa6226a2fd3dd3e05c4f9289fb48c05
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/Maps
Gerrit-Branch: master
Gerrit-Owner: Netbrain <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: MathiasLidal <[email protected]>
Gerrit-Reviewer: Netbrain <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to