http://www.mediawiki.org/wiki/Special:Code/MediaWiki/68995

Revision: 68995
Author:   jeroendedauw
Date:     2010-07-04 13:51:20 +0000 (Sun, 04 Jul 2010)

Log Message:
-----------
Improved support for google maps search bar

Modified Paths:
--------------
    trunk/extensions/Maps/Maps.php
    trunk/extensions/Maps/Services/GoogleMaps/GoogleMapFunctions.js

Modified: trunk/extensions/Maps/Maps.php
===================================================================
--- trunk/extensions/Maps/Maps.php      2010-07-04 13:07:07 UTC (rev 68994)
+++ trunk/extensions/Maps/Maps.php      2010-07-04 13:51:20 UTC (rev 68995)
@@ -33,7 +33,7 @@
        echo '<b>Warning:</b> You need to have <a 
href="http://www.mediawiki.org/wiki/Extension:Validator";>Validator</a> 
installed in order to use <a 
href="http://www.mediawiki.org/wiki/Extension:Maps";>Maps</a>.';
 }
 else {
-       define( 'Maps_VERSION', '0.6.4 a6' );
+       define( 'Maps_VERSION', '0.6.4 a7' );
 
        // The different coordinate notations.
        define( 'Maps_COORDS_FLOAT', 'float' );

Modified: trunk/extensions/Maps/Services/GoogleMaps/GoogleMapFunctions.js
===================================================================
--- trunk/extensions/Maps/Services/GoogleMaps/GoogleMapFunctions.js     
2010-07-04 13:07:07 UTC (rev 68994)
+++ trunk/extensions/Maps/Services/GoogleMaps/GoogleMapFunctions.js     
2010-07-04 13:51:20 UTC (rev 68995)
@@ -101,45 +101,59 @@
 
        map.setMapType(mapOptions.type);        
 
+       var hasSearchBar = false;
+       
+       for ( i = mapOptions.controls.length - 1; i >= 0; i-- ) {
+               if ( mapOptions.controls[i] == 'searchbar' ) {
+                       hasSearchBar = true;
+                       break;
+               }
+       }
+       
        // List of GControls: 
http://code.google.com/apis/maps/documentation/reference.html#GControl
-       for (i = 0; i < mapOptions.controls.length; i++){
-               if (mapOptions.controls[i].toLowerCase() == 'auto') {
-                       if (mapElement.offsetHeight > 75) 
mapOptions.controls[i] = mapElement.offsetHeight > 320 ? 'large' : 'small';
+       for ( i = 0; i < mapOptions.controls.length; i++ ) {
+               if ( mapOptions.controls[i].toLowerCase() == 'auto' ) {
+                       if ( mapElement.offsetHeight > 75 ) 
mapOptions.controls[i] = mapElement.offsetHeight > 320 ? 'large' : 'small';
                }                       
                
-               switch (mapOptions.controls[i]) {
+               switch ( mapOptions.controls[i] ) {
                        case 'large' : 
-                               map.addControl(new GLargeMapControl3D());
+                               map.addControl( new GLargeMapControl3D() );
                                break;
                        case 'small' : 
-                               map.addControl(new GSmallZoomControl3D());
+                               map.addControl( new GSmallZoomControl3D() );
                                break;
                        case 'large-original' : 
-                               map.addControl(new GLargeMapControl());
+                               map.addControl( new GLargeMapControl() );
                                break;
                        case 'small-original' : 
-                               map.addControl(new GSmallMapControl());
+                               map.addControl( new GSmallMapControl() );
                                break;
                        case 'zoom' : 
-                               map.addControl(new GSmallZoomControl());
+                               map.addControl( new GSmallZoomControl() );
                                break;
                        case 'type' : 
-                               map.addControl(new GMapTypeControl());
+                               map.addControl( new GMapTypeControl() );
                                break;                          
                        case 'type-menu' : 
-                               map.addControl(new GMenuMapTypeControl());
+                               map.addControl( new GMenuMapTypeControl() );
                                break;
                        case 'overlays' : 
-                               map.addControl(new MoreControl());
-                               break;                                  
+                               map.addControl( new MoreControl() );
+                               break;          
                        case 'overview' : case 'overview-map' : 
-                               map.addControl(new GOverviewMapControl());
-                               break;                                  
+                               map.addControl( new GOverviewMapControl() );
+                               break;
                        case 'scale' : 
-                               map.addControl(new GScaleControl());
+                               if ( hasSearchBar ) {
+                                       map.addControl( new GScaleControl(), 
new GControlPosition( G_ANCHOR_BOTTOM_LEFT, new GSize( 5,37 ) ) );
+                               }
+                               else {
+                                       map.addControl( new GScaleControl() );
+                               }
                                break;
                        case 'nav-label' : case 'nav' : 
-                               map.addControl(new GNavLabelControl());
+                               map.addControl( new GNavLabelControl() );
                                break;
                        case 'searchbar' :
                                map.enableGoogleBar();
@@ -168,7 +182,7 @@
        
        // Code to add KML files.
        var kmlOverlays = [];
-       for ( i = mapOptions.kml.length -1; i >= 0; i-- ) {
+       for ( i = mapOptions.kml.length - 1; i >= 0; i-- ) {
                kmlOverlays[i] = new GGeoXml( mapOptions.kml[i] );
                map.addOverlay( kmlOverlays[i] );
        }



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

Reply via email to