Index: trunk/extensions/Maps/includes/services/OpenLayers/jquery.openlayers.js |
— | — | @@ -92,7 +92,7 @@ |
93 | 93 | control = getValidControlName( controls[i] ); |
94 | 94 | |
95 | 95 | if ( control ) { |
96 | | - eval(' map.addControl( new OpenLayers.Control.' + control + '() ); '); |
| 96 | + map.addControl(eval('new OpenLayers.Control.' + control + '() ')); |
97 | 97 | } |
98 | 98 | } |
99 | 99 | else { |
— | — | @@ -178,21 +178,22 @@ |
179 | 179 | // Remove the loading map message. |
180 | 180 | this.text( '' ); |
181 | 181 | |
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 | | - |
191 | 182 | // Create a new OpenLayers map with without any controls on it. |
192 | 183 | var mapOptions = { |
193 | 184 | controls: [] |
194 | 185 | }; |
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 ) { |
197 | 198 | mapOptions.projection = new OpenLayers.Projection("EPSG:900913"); |
198 | 199 | mapOptions.displayProjection = new OpenLayers.Projection("EPSG:4326"); |
199 | 200 | mapOptions.units = "m"; |
— | — | @@ -207,7 +208,7 @@ |
208 | 209 | |
209 | 210 | // Add the base layers. |
210 | 211 | for ( i = 0, n = options.layers.length; i < n; i++ ) { |
211 | | - map.addLayer( eval( options.layers[i] ) ); |
| 212 | + map.addLayer(options.layers[i] ); |
212 | 213 | } |
213 | 214 | |
214 | 215 | //Add markers |
— | — | @@ -297,6 +298,10 @@ |
298 | 299 | } |
299 | 300 | } |
300 | 301 | |
| 302 | + if ( options.zoom !== false ) { |
| 303 | + map.zoomTo( options.zoom ); |
| 304 | + } |
| 305 | + |
301 | 306 | if ( options.centre === false ) { |
302 | 307 | if ( options.locations.length == 1 ) { |
303 | 308 | centre = new OpenLayers.LonLat( options.locations[0].lon, options.locations[0].lat ); |
— | — | @@ -312,15 +317,12 @@ |
313 | 318 | if ( centre !== false ) { |
314 | 319 | if ( !hasImageLayer ) { |
315 | 320 | 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 | + } |
319 | 325 | } |
320 | 326 | |
321 | | - if ( options.zoom !== false ) { |
322 | | - map.zoomTo( options.zoom ); |
323 | | - } |
324 | | - |
325 | 327 | if ( options.resizable ) { |
326 | 328 | mw.loader.using( 'ext.maps.resizable', function() { |
327 | 329 | _this.resizable(); |
— | — | @@ -368,7 +370,6 @@ |
369 | 371 | if(options.markercluster){ |
370 | 372 | alert(mediaWiki.msg('maps-clustering-unsupportedservice')); |
371 | 373 | } |
372 | | - |
373 | 374 | return this; |
374 | 375 | |
375 | 376 | }; })( jQuery ); |