Index: trunk/extensions/Maps/OpenLayers/Maps_OpenLayers.php |
— | — | @@ -58,23 +58,66 @@ |
59 | 59 | 'default' => $egMapsOpenLayersZoom, |
60 | 60 | ), |
61 | 61 | 'controls' => array( |
62 | | - 'criteria' => array(), // TODO |
| 62 | + 'criteria' => array( |
| 63 | + 'in_array' => self::getControlNames() |
| 64 | + ), |
63 | 65 | 'default' => implode(',', $egMapsOLControls) |
64 | 66 | ), |
65 | 67 | 'layers' => array( |
66 | 68 | 'aliases' => array(), |
67 | | - 'criteria' => array(), // TODO |
| 69 | + 'criteria' => array( |
| 70 | + 'in_array' => self::getLayerNames() |
| 71 | + ), |
68 | 72 | 'default' => implode(',', $egMapsOLLayers) |
69 | | - ), |
| 73 | + ), |
| 74 | + /* |
70 | 75 | 'baselayer' => array( // TODO |
71 | 76 | 'aliases' => array(), |
72 | 77 | 'criteria' => array(), |
73 | 78 | 'default' => '' |
74 | 79 | ), |
| 80 | + */ |
75 | 81 | ); |
76 | 82 | } |
77 | 83 | |
78 | 84 | /** |
| 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 | + /** |
79 | 122 | * Load the dependencies of a layer if they are not loaded yet |
80 | 123 | * |
81 | 124 | * @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 @@ |
31 | 31 | |
32 | 32 | // Only initialize the extension when all dependencies are present. |
33 | 33 | if (defined( 'Validator_VERSION' )) { |
34 | | - define('Maps_VERSION', '0.5 a18'); |
| 34 | + define('Maps_VERSION', '0.5 a19'); |
35 | 35 | |
36 | 36 | $egMapsScriptPath = $wgScriptPath . '/extensions/Maps'; |
37 | 37 | $egMapsIP = $IP . '/extensions/Maps'; |
Index: trunk/extensions/Maps/OpenStreetMap/OSMFunctions.js |
— | — | @@ -82,31 +82,7 @@ |
83 | 83 | |
84 | 84 | for (key in mapParams) |
85 | 85 | 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 | | - */ |
101 | 86 | |
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 | | - |
111 | 87 | // Add the controls |
112 | 88 | this.mapOptions = {controls: []}; |
113 | 89 | |
— | — | @@ -120,7 +96,7 @@ |
121 | 97 | if (control) { |
122 | 98 | eval(' this.mapOptions.controls.push( new OpenLayers.Control.' + control + '() ); '); |
123 | 99 | } |
124 | | - } |
| 100 | + } |
125 | 101 | } |
126 | 102 | |
127 | 103 | slippymap_map.prototype.init = function() { |
— | — | @@ -129,7 +105,7 @@ |
130 | 106 | if (previewImage) |
131 | 107 | previewImage.style.display = 'none'; |
132 | 108 | |
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); |
134 | 110 | |
135 | 111 | var centerIsSet = this.lon != null && this.lat != null; |
136 | 112 | |
— | — | @@ -163,10 +139,17 @@ |
164 | 140 | if (this.zoom != null) this.map.zoomTo(this.zoom); // When the zoom is provided, set it |
165 | 141 | } |
166 | 142 | |
167 | | -slippymap_map.prototype.osm_create = function(mapId, lon, lat, zoom) { |
| 143 | +slippymap_map.prototype.osm_create = function(mapId, lon, lat, zoom, initializedContols) { |
168 | 144 | var osmLayer; |
169 | 145 | var map = new OpenLayers.Map(mapId, this.mapOptions /* all provided for by OSM.js */); |
170 | 146 | |
| 147 | + if (initializedContols) { |
| 148 | + for (i in initializedContols) { |
| 149 | + map.addControl(initializedContols[i]); |
| 150 | + initializedContols[i].activate(); |
| 151 | + } |
| 152 | + } |
| 153 | + |
171 | 154 | if (this.layer == 'osm-like') { |
172 | 155 | osmLayer = new OpenLayers.Layer.OSM("OpenStreetMaps", 'http://cassini.toolserver.org/tiles/osm-like/' + this.locale + '/${z}/${x}/${y}.png'); |
173 | 156 | } |
— | — | @@ -176,23 +159,6 @@ |
177 | 160 | return map; |
178 | 161 | } |
179 | 162 | |
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 | | - |
197 | 163 | function getOSMMarkerData(lon, lat, title, label, icon) { |
198 | 164 | lonLat = new OpenLayers.LonLat(lon, lat); |
199 | 165 | return { |
Index: trunk/extensions/Maps/OpenStreetMap/Maps_OSM.php |
— | — | @@ -69,6 +69,26 @@ |
70 | 70 | ); |
71 | 71 | } |
72 | 72 | |
| 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 | + |
73 | 93 | private static $modes = array( |
74 | 94 | 'osm-wm' => array( |
75 | 95 | // First layer = default |
Index: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMaps.php |
— | — | @@ -142,6 +142,15 @@ |
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
| 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 | + /** |
146 | 155 | * Returns the Google Map type (defined in MapsGoogleMaps::$mapTypes) |
147 | 156 | * for the provided a general map type. When no match is found, false |
148 | 157 | * will be returned. |