r68995 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68994‎ | r68995 | r68996 >
Date:13:51, 4 July 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Improved support for google maps search bar
Modified paths:
  • /trunk/extensions/Maps/Maps.php (modified) (history)
  • /trunk/extensions/Maps/Services/GoogleMaps/GoogleMapFunctions.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Maps/Services/GoogleMaps/GoogleMapFunctions.js
@@ -101,45 +101,59 @@
102102
103103 map.setMapType(mapOptions.type);
104104
 105+ var hasSearchBar = false;
 106+
 107+ for ( i = mapOptions.controls.length - 1; i >= 0; i-- ) {
 108+ if ( mapOptions.controls[i] == 'searchbar' ) {
 109+ hasSearchBar = true;
 110+ break;
 111+ }
 112+ }
 113+
105114 // List of GControls: http://code.google.com/apis/maps/documentation/reference.html#GControl
106 - for (i = 0; i < mapOptions.controls.length; i++){
107 - if (mapOptions.controls[i].toLowerCase() == 'auto') {
108 - if (mapElement.offsetHeight > 75) mapOptions.controls[i] = mapElement.offsetHeight > 320 ? 'large' : 'small';
 115+ for ( i = 0; i < mapOptions.controls.length; i++ ) {
 116+ if ( mapOptions.controls[i].toLowerCase() == 'auto' ) {
 117+ if ( mapElement.offsetHeight > 75 ) mapOptions.controls[i] = mapElement.offsetHeight > 320 ? 'large' : 'small';
109118 }
110119
111 - switch (mapOptions.controls[i]) {
 120+ switch ( mapOptions.controls[i] ) {
112121 case 'large' :
113 - map.addControl(new GLargeMapControl3D());
 122+ map.addControl( new GLargeMapControl3D() );
114123 break;
115124 case 'small' :
116 - map.addControl(new GSmallZoomControl3D());
 125+ map.addControl( new GSmallZoomControl3D() );
117126 break;
118127 case 'large-original' :
119 - map.addControl(new GLargeMapControl());
 128+ map.addControl( new GLargeMapControl() );
120129 break;
121130 case 'small-original' :
122 - map.addControl(new GSmallMapControl());
 131+ map.addControl( new GSmallMapControl() );
123132 break;
124133 case 'zoom' :
125 - map.addControl(new GSmallZoomControl());
 134+ map.addControl( new GSmallZoomControl() );
126135 break;
127136 case 'type' :
128 - map.addControl(new GMapTypeControl());
 137+ map.addControl( new GMapTypeControl() );
129138 break;
130139 case 'type-menu' :
131 - map.addControl(new GMenuMapTypeControl());
 140+ map.addControl( new GMenuMapTypeControl() );
132141 break;
133142 case 'overlays' :
134 - map.addControl(new MoreControl());
135 - break;
 143+ map.addControl( new MoreControl() );
 144+ break;
136145 case 'overview' : case 'overview-map' :
137 - map.addControl(new GOverviewMapControl());
138 - break;
 146+ map.addControl( new GOverviewMapControl() );
 147+ break;
139148 case 'scale' :
140 - map.addControl(new GScaleControl());
 149+ if ( hasSearchBar ) {
 150+ map.addControl( new GScaleControl(), new GControlPosition( G_ANCHOR_BOTTOM_LEFT, new GSize( 5,37 ) ) );
 151+ }
 152+ else {
 153+ map.addControl( new GScaleControl() );
 154+ }
141155 break;
142156 case 'nav-label' : case 'nav' :
143 - map.addControl(new GNavLabelControl());
 157+ map.addControl( new GNavLabelControl() );
144158 break;
145159 case 'searchbar' :
146160 map.enableGoogleBar();
@@ -168,7 +182,7 @@
169183
170184 // Code to add KML files.
171185 var kmlOverlays = [];
172 - for ( i = mapOptions.kml.length -1; i >= 0; i-- ) {
 186+ for ( i = mapOptions.kml.length - 1; i >= 0; i-- ) {
173187 kmlOverlays[i] = new GGeoXml( mapOptions.kml[i] );
174188 map.addOverlay( kmlOverlays[i] );
175189 }
Index: trunk/extensions/Maps/Maps.php
@@ -33,7 +33,7 @@
3434 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>.';
3535 }
3636 else {
37 - define( 'Maps_VERSION', '0.6.4 a6' );
 37+ define( 'Maps_VERSION', '0.6.4 a7' );
3838
3939 // The different coordinate notations.
4040 define( 'Maps_COORDS_FLOAT', 'float' );

Status & tagging log