r74989 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74988‎ | r74989 | r74990 >
Date:00:50, 19 October 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.7.1 - changes to the OpenLayers JS to allow for correctly settings markers on image layers
Modified paths:
  • /trunk/extensions/Maps/includes/Maps_Layer.php (modified) (history)
  • /trunk/extensions/Maps/includes/services/OpenLayers/OpenLayerFunctions.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Maps/includes/Maps_Layer.php
@@ -184,6 +184,8 @@
185185 * Returns a string containing the JavaScript definition of this layer.
186186 * Only call this function when you are sure the layer is valid!
187187 *
 188+ * TODO: move this to the OpenLayers class
 189+ *
188190 * @since 0.7.1
189191 *
190192 * @return string
@@ -195,7 +197,7 @@
196198
197199 $class = self::$types[$this->getType()]['class'];
198200
199 - $options = array();
 201+ $options = array( 'isImage' => true );
200202
201203 if ( $this->properties !== false ) {
202204 $options['numZoomLevels'] = $zoomlevels;
Index: trunk/extensions/Maps/includes/services/OpenLayers/OpenLayerFunctions.js
@@ -6,7 +6,7 @@
77 *
88 * @author Jeroen De Dauw
99 */
10 -
 10+
1111 /**
1212 * Creates and initializes an OpenLayers map.
1313 * The resulting map is returned by the function but no further handling is required in most cases.
@@ -15,16 +15,28 @@
1616
1717 OpenLayers.Lang.setCode( langCode );
1818
 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+
1928 // 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 = {
2730 controls: []
2831 };
 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+ }
2941
3042 var mapElement = document.getElementById( mapName );
3143
@@ -73,7 +85,11 @@
7486
7587 for ( i = marker_data.length - 1; i >= 0; i-- ) {
7688 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+
7894 if ( bounds != null ) bounds.extend( marker_data[i].lonlat ); // Extend the bounds when no center is set.
7995 markerLayer.addMarker( getOLMarker( markerLayer, marker_data[i], map.getProjectionObject() ) ); // Create and add the marker.
8096 }
@@ -82,7 +98,11 @@
8399
84100 if (centerIsSet) { // When the center is provided, set it.
85101 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+
87107 map.setCenter(centre);
88108 }
89109

Status & tagging log