Index: trunk/extensions/Maps/includes/Maps_Layer.php |
— | — | @@ -184,6 +184,8 @@ |
185 | 185 | * Returns a string containing the JavaScript definition of this layer. |
186 | 186 | * Only call this function when you are sure the layer is valid! |
187 | 187 | * |
| 188 | + * TODO: move this to the OpenLayers class |
| 189 | + * |
188 | 190 | * @since 0.7.1 |
189 | 191 | * |
190 | 192 | * @return string |
— | — | @@ -195,7 +197,7 @@ |
196 | 198 | |
197 | 199 | $class = self::$types[$this->getType()]['class']; |
198 | 200 | |
199 | | - $options = array(); |
| 201 | + $options = array( 'isImage' => true ); |
200 | 202 | |
201 | 203 | if ( $this->properties !== false ) { |
202 | 204 | $options['numZoomLevels'] = $zoomlevels; |
Index: trunk/extensions/Maps/includes/services/OpenLayers/OpenLayerFunctions.js |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | * |
8 | 8 | * @author Jeroen De Dauw |
9 | 9 | */ |
10 | | - |
| 10 | + |
11 | 11 | /** |
12 | 12 | * Creates and initializes an OpenLayers map. |
13 | 13 | * The resulting map is returned by the function but no further handling is required in most cases. |
— | — | @@ -15,16 +15,28 @@ |
16 | 16 | |
17 | 17 | OpenLayers.Lang.setCode( langCode ); |
18 | 18 | |
| 19 | + var hasImageLayer = false; |
| 20 | + for ( i = 0, n = mapTypes.length; i < n; i++ ) { |
| 21 | + // Idieally this would check if the objecct is of type OpenLayers.layer.image |
| 22 | + if ( mapTypes[i].options && mapTypes[i].options.isImage === true ) { |
| 23 | + hasImageLayer = true; |
| 24 | + break; |
| 25 | + } |
| 26 | + } |
| 27 | + |
19 | 28 | // Create a new OpenLayers map with without any controls on it. |
20 | | - var mapOptions = { |
21 | | - projection: new OpenLayers.Projection("EPSG:900913"), |
22 | | - displayProjection: new OpenLayers.Projection("EPSG:4326"), |
23 | | - units: "m", |
24 | | - numZoomLevels: 18, |
25 | | - maxResolution: 156543.0339, |
26 | | - maxExtent: new OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508.34), |
| 29 | + var mapOptions = { |
27 | 30 | controls: [] |
28 | 31 | }; |
| 32 | + |
| 33 | + if ( !hasImageLayer ) { |
| 34 | + mapOptions.projection = new OpenLayers.Projection("EPSG:900913"); |
| 35 | + mapOptions.displayProjection = new OpenLayers.Projection("EPSG:4326"); |
| 36 | + mapOptions.units = "m"; |
| 37 | + mapOptions.numZoomLevels = 18; |
| 38 | + mapOptions.maxResolution = 156543.0339; |
| 39 | + mapOptions.maxExtent = new OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508.34); |
| 40 | + } |
29 | 41 | |
30 | 42 | var mapElement = document.getElementById( mapName ); |
31 | 43 | |
— | — | @@ -73,7 +85,11 @@ |
74 | 86 | |
75 | 87 | for ( i = marker_data.length - 1; i >= 0; i-- ) { |
76 | 88 | marker_data[i].lonlat = new OpenLayers.LonLat( marker_data[i].lon, marker_data[i].lat ); |
77 | | - marker_data[i].lonlat.transform( new OpenLayers.Projection( "EPSG:4326" ), new OpenLayers.Projection( "EPSG:900913" ) ); |
| 89 | + |
| 90 | + if ( !hasImageLayer ) { |
| 91 | + marker_data[i].lonlat.transform( new OpenLayers.Projection( "EPSG:4326" ), new OpenLayers.Projection( "EPSG:900913" ) ); |
| 92 | + } |
| 93 | + |
78 | 94 | if ( bounds != null ) bounds.extend( marker_data[i].lonlat ); // Extend the bounds when no center is set. |
79 | 95 | markerLayer.addMarker( getOLMarker( markerLayer, marker_data[i], map.getProjectionObject() ) ); // Create and add the marker. |
80 | 96 | } |
— | — | @@ -82,7 +98,11 @@ |
83 | 99 | |
84 | 100 | if (centerIsSet) { // When the center is provided, set it. |
85 | 101 | var centre = new OpenLayers.LonLat(lon, lat); |
86 | | - centre.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913")); |
| 102 | + |
| 103 | + if ( !hasImageLayer ) { |
| 104 | + centre.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913")); |
| 105 | + } |
| 106 | + |
87 | 107 | map.setCenter(centre); |
88 | 108 | } |
89 | 109 | |