r114652 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114651‎ | r114652 | r114653 >
Date:13:28, 2 April 2012
Author:netbrain
Status:deferred
Tags:
Comment:
fixed openlayers js for image layer capability.
and did some minor js optimizations
Modified paths:
  • /trunk/extensions/Maps/includes/services/OpenLayers/jquery.openlayers.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Maps/includes/services/OpenLayers/jquery.openlayers.js
@@ -92,7 +92,7 @@
9393 control = getValidControlName( controls[i] );
9494
9595 if ( control ) {
96 - eval(' map.addControl( new OpenLayers.Control.' + control + '() ); ');
 96+ map.addControl(eval('new OpenLayers.Control.' + control + '() '));
9797 }
9898 }
9999 else {
@@ -178,21 +178,22 @@
179179 // Remove the loading map message.
180180 this.text( '' );
181181
182 - var hasImageLayer = false;
183 - for ( i = 0, n = options.layers.length; i < n; i++ ) {
184 - // Idieally this would check if the objecct is of type OpenLayers.layer.image
185 - if ( options.layers[i].options && options.layers[i].options.isImage === true ) {
186 - hasImageLayer = true;
187 - break;
188 - }
189 - }
190 -
191182 // Create a new OpenLayers map with without any controls on it.
192183 var mapOptions = {
193184 controls: []
194185 };
195 -
196 - if ( !hasImageLayer ) {
 186+
 187+ var hasImageLayer = false;
 188+ for ( i = 0, n = options.layers.length; i < n; i++ ) {
 189+ // Idieally this would check if the objecct is of type OpenLayers.layer.image
 190+ options.layers[i] = eval(options.layers[i])
 191+ if ( options.layers[i].options && options.layers[i].options.isImage === true ) {
 192+ hasImageLayer = true;
 193+ break;
 194+ }
 195+ }
 196+
 197+ if ( !hasImageLayer ) {
197198 mapOptions.projection = new OpenLayers.Projection("EPSG:900913");
198199 mapOptions.displayProjection = new OpenLayers.Projection("EPSG:4326");
199200 mapOptions.units = "m";
@@ -207,7 +208,7 @@
208209
209210 // Add the base layers.
210211 for ( i = 0, n = options.layers.length; i < n; i++ ) {
211 - map.addLayer( eval( options.layers[i] ) );
 212+ map.addLayer(options.layers[i] );
212213 }
213214
214215 //Add markers
@@ -297,6 +298,10 @@
298299 }
299300 }
300301
 302+ if ( options.zoom !== false ) {
 303+ map.zoomTo( options.zoom );
 304+ }
 305+
301306 if ( options.centre === false ) {
302307 if ( options.locations.length == 1 ) {
303308 centre = new OpenLayers.LonLat( options.locations[0].lon, options.locations[0].lat );
@@ -312,15 +317,12 @@
313318 if ( centre !== false ) {
314319 if ( !hasImageLayer ) {
315320 centre.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
316 - }
317 -
318 - map.setCenter( centre );
 321+ map.setCenter( centre );
 322+ }else{
 323+ map.zoomToMaxExtent();
 324+ }
319325 }
320326
321 - if ( options.zoom !== false ) {
322 - map.zoomTo( options.zoom );
323 - }
324 -
325327 if ( options.resizable ) {
326328 mw.loader.using( 'ext.maps.resizable', function() {
327329 _this.resizable();
@@ -368,7 +370,6 @@
369371 if(options.markercluster){
370372 alert(mediaWiki.msg('maps-clustering-unsupportedservice'));
371373 }
372 -
373374 return this;
374375
375376 }; })( jQuery );

Status & tagging log