r59856 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59855‎ | r59856 | r59857 >
Date:22:34, 8 December 2009
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Added getParameters support.
Modified paths:
  • /trunk/extensions/Maps/GoogleMaps/Maps_GoogleMaps.php (modified) (history)
  • /trunk/extensions/Maps/Maps.php (modified) (history)
  • /trunk/extensions/Maps/OpenLayers/Maps_OpenLayers.php (modified) (history)
  • /trunk/extensions/Maps/OpenStreetMap/Maps_OSM.php (modified) (history)
  • /trunk/extensions/Maps/OpenStreetMap/OSMFunctions.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Maps/OpenLayers/Maps_OpenLayers.php
@@ -58,23 +58,66 @@
5959 'default' => $egMapsOpenLayersZoom,
6060 ),
6161 'controls' => array(
62 - 'criteria' => array(), // TODO
 62+ 'criteria' => array(
 63+ 'in_array' => self::getControlNames()
 64+ ),
6365 'default' => implode(',', $egMapsOLControls)
6466 ),
6567 'layers' => array(
6668 'aliases' => array(),
67 - 'criteria' => array(), // TODO
 69+ 'criteria' => array(
 70+ 'in_array' => self::getLayerNames()
 71+ ),
6872 'default' => implode(',', $egMapsOLLayers)
69 - ),
 73+ ),
 74+ /*
7075 'baselayer' => array( // TODO
7176 'aliases' => array(),
7277 'criteria' => array(),
7378 'default' => ''
7479 ),
 80+ */
7581 );
7682 }
7783
7884 /**
 85+ * Returns the names of all supported controls.
 86+ * This data is a copy of the one used to actually translate the names
 87+ * into the controls, since this resides client side, in OpenLayerFunctions.js.
 88+ *
 89+ * @return array
 90+ */
 91+ public static function getControlNames() {
 92+ return array(
 93+ 'ArgParser', 'Attribution', 'Button', 'DragFeature', 'DragPan',
 94+ 'DrawFeature', 'EditingToolbar', 'GetFeature', 'KeyboardDefaults', 'LayerSwitcher',
 95+ 'Measure', 'ModifyFeature', 'MouseDefaults', 'MousePosition', 'MouseToolbar',
 96+ 'Navigation', 'NavigationHistory', 'NavToolbar', 'OverviewMap', 'Pan',
 97+ 'Panel', 'PanPanel', 'PanZoom', 'PanZoomBar', 'AutoPanZoom', 'Permalink',
 98+ 'Scale', 'ScaleLine', 'SelectFeature', 'Snapping', 'Split',
 99+ 'WMSGetFeatureInfo', 'ZoomBox', 'ZoomIn', 'ZoomOut', 'ZoomPanel',
 100+ 'ZoomToMaxExtent'
 101+ );
 102+ }
 103+
 104+ /**
 105+ * Returns the names of all supported layers.
 106+ * This data is a copy of the one used to actually translate the names
 107+ * into the layers, since this resides client side, in OpenLayerFunctions.js.
 108+ *
 109+ * @return array
 110+ */
 111+ public static function getLayerNames() {
 112+ return array(
 113+ 'google', 'google-normal', 'google-satellite', 'google-hybrid', 'google-hybrid', 'google-physical',
 114+ 'bing', 'bing-normal', 'bing-satellite', 'bing-hybrid',
 115+ 'yahoo', 'yahoo-normal', 'yahoo-satellite', 'yahoo-hybrid',
 116+ 'openlayers', 'nasa',
 117+ 'openstreetmap', 'osmarender', 'osm-nik', 'osm-cycle'
 118+ );
 119+ }
 120+
 121+ /**
79122 * Load the dependencies of a layer if they are not loaded yet
80123 *
81124 * @param string $output The output to which the html to load the dependencies needs to be added
Index: trunk/extensions/Maps/Maps.php
@@ -30,7 +30,7 @@
3131
3232 // Only initialize the extension when all dependencies are present.
3333 if (defined( 'Validator_VERSION' )) {
34 - define('Maps_VERSION', '0.5 a18');
 34+ define('Maps_VERSION', '0.5 a19');
3535
3636 $egMapsScriptPath = $wgScriptPath . '/extensions/Maps';
3737 $egMapsIP = $IP . '/extensions/Maps';
Index: trunk/extensions/Maps/OpenStreetMap/OSMFunctions.js
@@ -82,31 +82,7 @@
8383
8484 for (key in mapParams)
8585 this[key] = mapParams[key];
86 -
87 - /*
88 - var buttonsPanel = new OpenLayers.Control.Panel( { displayClass: "buttonsPanel" } );
89 - buttonsPanel.addControls([ new OpenLayers.Control.Button({
90 - title: wgSlippyMapButtonCode,
91 - displayClass: "getWikiCodeButton",
92 - trigger: function() { self.getWikicode(); }
93 - }),
94 - new OpenLayers.Control.Button({
95 - title: wgSlippyMapResetview,
96 - displayClass: "resetButton",
97 - trigger: function() { self.resetPosition(); }
98 - })
99 - ]);
100 - */
10186
102 - /*
103 - this.mapOptions = { controls: [ new OpenLayers.Control.Navigation(),
104 - new OpenLayers.Control.ArgParser(),
105 - new OpenLayers.Control.Attribution(),
106 - // buttonsPanel
107 - ]
108 - };
109 - */
110 -
11187 // Add the controls
11288 this.mapOptions = {controls: []};
11389
@@ -120,7 +96,7 @@
12197 if (control) {
12298 eval(' this.mapOptions.controls.push( new OpenLayers.Control.' + control + '() ); ');
12399 }
124 - }
 100+ }
125101 }
126102
127103 slippymap_map.prototype.init = function() {
@@ -129,7 +105,7 @@
130106 if (previewImage)
131107 previewImage.style.display = 'none';
132108
133 - this.map = this.osm_create(this.mapId, this.lon, this.lat, this.zoom);
 109+ this.map = this.osm_create(this.mapId, this.lon, this.lat, this.zoom, this.initializedContols);
134110
135111 var centerIsSet = this.lon != null && this.lat != null;
136112
@@ -163,10 +139,17 @@
164140 if (this.zoom != null) this.map.zoomTo(this.zoom); // When the zoom is provided, set it
165141 }
166142
167 -slippymap_map.prototype.osm_create = function(mapId, lon, lat, zoom) {
 143+slippymap_map.prototype.osm_create = function(mapId, lon, lat, zoom, initializedContols) {
168144 var osmLayer;
169145 var map = new OpenLayers.Map(mapId, this.mapOptions /* all provided for by OSM.js */);
170146
 147+ if (initializedContols) {
 148+ for (i in initializedContols) {
 149+ map.addControl(initializedContols[i]);
 150+ initializedContols[i].activate();
 151+ }
 152+ }
 153+
171154 if (this.layer == 'osm-like') {
172155 osmLayer = new OpenLayers.Layer.OSM("OpenStreetMaps", 'http://cassini.toolserver.org/tiles/osm-like/' + this.locale + '/${z}/${x}/${y}.png');
173156 }
@@ -176,23 +159,6 @@
177160 return map;
178161 }
179162
180 -/*
181 -slippymap_map.prototype.resetPosition = function() {
182 - this.map.setCenter(new OpenLayers.LonLat(this.lon, this.lat).transform(new OpenLayers.Projection('EPSG:4326'), this.map.getProjectionObject()), this.zoom);
183 -}
184 -
185 -slippymap_map.prototype.getWikicode = function() {
186 - LL = this.map.getCenter().transform(this.map.getProjectionObject(), new OpenLayers.Projection("EPSG:4326"));
187 - Z = this.map.getZoom();
188 - size = this.map.getSize();
189 -
190 - prompt(
191 - wgSlippyMapCode,
192 - "<slippymap lat=" + LL.lat + " lon=" + LL.lon + " zoom=" + Z + " width=" + size.w + " height=" + size.h + " mode=" + this.mode + " layer=" + this.layer + (this.marker == 0 ? "" : " marker=" + this.marker) + " />"
193 - );
194 -}
195 -*/
196 -
197163 function getOSMMarkerData(lon, lat, title, label, icon) {
198164 lonLat = new OpenLayers.LonLat(lon, lat);
199165 return {
Index: trunk/extensions/Maps/OpenStreetMap/Maps_OSM.php
@@ -69,6 +69,26 @@
7070 );
7171 }
7272
 73+ /**
 74+ * Returns the names of all supported controls.
 75+ * This data is a copy of the one used to actually translate the names
 76+ * into the controls, since this resides client side, in OSMFunctions.js.
 77+ *
 78+ * @return array
 79+ */
 80+ public static function getControlNames() {
 81+ return array(
 82+ 'ArgParser', 'Attribution', 'Button', 'DragFeature', 'DragPan',
 83+ 'DrawFeature', 'EditingToolbar', 'GetFeature', 'KeyboardDefaults', 'LayerSwitcher',
 84+ 'Measure', 'ModifyFeature', 'MouseDefaults', 'MousePosition', 'MouseToolbar',
 85+ 'Navigation', 'NavigationHistory', 'NavToolbar', 'OverviewMap', 'Pan',
 86+ 'Panel', 'PanPanel', 'PanZoom', 'PanZoomBar', 'AutoPanZoom', 'Permalink',
 87+ 'Scale', 'ScaleLine', 'SelectFeature', 'Snapping', 'Split',
 88+ 'WMSGetFeatureInfo', 'ZoomBox', 'ZoomIn', 'ZoomOut', 'ZoomPanel',
 89+ 'ZoomToMaxExtent'
 90+ );
 91+ }
 92+
7393 private static $modes = array(
7494 'osm-wm' => array(
7595 // First layer = default
Index: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMaps.php
@@ -142,6 +142,15 @@
143143 }
144144
145145 /**
 146+ * Returns the names of all supported map overlays.
 147+ *
 148+ * @return array
 149+ */
 150+ public static function getOverlayNames() {
 151+ return array_keys(self::$overlayData);
 152+ }
 153+
 154+ /**
146155 * Returns the Google Map type (defined in MapsGoogleMaps::$mapTypes)
147156 * for the provided a general map type. When no match is found, false
148157 * will be returned.

Status & tagging log