Index: trunk/extensions/Maps/OpenLayers/Maps_OpenLayersDispPoint.php |
— | — | @@ -66,8 +66,8 @@ |
67 | 67 | $label = array_key_exists('label', $markerData) ? $markerData['label'] : $this->label; |
68 | 68 | |
69 | 69 | $title = str_replace("'", "\'", $title); |
70 | | - $label = str_replace("'", "\'", $label); |
71 | | - |
| 70 | + $label = str_replace("'", "\'", $label); |
| 71 | + |
72 | 72 | $icon = array_key_exists('icon', $markerData) ? $markerData['icon'] : ''; |
73 | 73 | $markerItems[] = "getOLMarkerData($lon, $lat, '$title', '$label', '$icon')"; |
74 | 74 | } |
— | — | @@ -77,7 +77,7 @@ |
78 | 78 | $this->output .= "<div id='$this->mapName' style='width: {$this->width}px; height: {$this->height}px; background-color: #cccccc;'></div> |
79 | 79 | <script type='$wgJsMimeType'> /*<![CDATA[*/ |
80 | 80 | addOnloadHook( |
81 | | - initOpenLayer('$this->mapName', $this->centre_lon, $this->centre_lat, $this->zoom, [$layerItems], [$controlItems],[$markersString]) |
| 81 | + initOpenLayer('$this->mapName', $this->centre_lon, $this->centre_lat, $this->zoom, [$layerItems], [$controlItems],[$markersString], $this->height) |
82 | 82 | ); |
83 | 83 | /*]]>*/ </script>"; |
84 | 84 | } |
Index: trunk/extensions/Maps/OpenLayers/OpenLayerFunctions.js |
— | — | @@ -11,7 +11,7 @@ |
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. |
14 | 14 | */ |
15 | | -function initOpenLayer(mapName, lon, lat, zoom, mapTypes, controls, marker_data){ |
| 15 | +function initOpenLayer(mapName, lon, lat, zoom, mapTypes, controls, marker_data, height){ |
16 | 16 | |
17 | 17 | // Create a new OpenLayers map with without any controls on it |
18 | 18 | var mapOptions = { |
— | — | @@ -31,6 +31,10 @@ |
32 | 32 | |
33 | 33 | // If a string is provided, find the correct name for the control, and use eval to create the object itself |
34 | 34 | if (typeof controls[i] == 'string') { |
| 35 | + if (controls[i].toLowerCase() == 'autopanzoom') { |
| 36 | + if (height > 140) controls[i] = height > 320 ? 'panzoombar' : 'panzoom'; |
| 37 | + } |
| 38 | + |
35 | 39 | control = getValidControlName(controls[i]); |
36 | 40 | |
37 | 41 | if (control) { |
Index: trunk/extensions/Maps/OpenLayers/Maps_OpenLayersDispMap.php |
— | — | @@ -58,7 +58,7 @@ |
59 | 59 | $this->output .= "<div id='$this->mapName' style='width: {$this->width}px; height: {$this->height}px; background-color: #cccccc;'></div> |
60 | 60 | <script type='$wgJsMimeType'> /*<![CDATA[*/ |
61 | 61 | addOnloadHook( |
62 | | - initOpenLayer('$this->mapName', $this->centre_lon, $this->centre_lat, $this->zoom, [$layerItems], [$controlItems],[]) |
| 62 | + initOpenLayer('$this->mapName', $this->centre_lon, $this->centre_lat, $this->zoom, [$layerItems], [$controlItems],[], $this->height) |
63 | 63 | ); |
64 | 64 | /*]]>*/ </script>"; |
65 | 65 | } |
Index: trunk/extensions/Maps/Maps.php |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | die( 'Not an entry point.' ); |
25 | 25 | } |
26 | 26 | |
27 | | -define('Maps_VERSION', '0.4 a9'); |
| 27 | +define('Maps_VERSION', '0.4 a10'); |
28 | 28 | |
29 | 29 | $egMapsScriptPath = $wgScriptPath . '/extensions/Maps'; |
30 | 30 | $egMapsIP = $IP . '/extensions/Maps'; |
Index: trunk/extensions/Maps/Maps_Mapper.php |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -/** |
| 4 | +/** |
5 | 5 | * A class that holds static helper functions for common functionality that is not map-spesific. |
6 | 6 | * |
7 | 7 | * @file Maps_Mapper.php |
Index: trunk/extensions/Maps/Maps_MapFeature.php |
— | — | @@ -17,19 +17,16 @@ |
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Set the map service specific element name and the javascript function handling the displaying of an address |
21 | | - * |
22 | 21 | */ |
23 | 22 | protected abstract function setMapSettings(); |
24 | 23 | |
25 | 24 | /** |
26 | 25 | * Map service specific map count and loading of dependencies |
27 | | - * |
28 | 26 | */ |
29 | 27 | protected abstract function doMapServiceLoad(); |
30 | 28 | |
31 | 29 | /** |
32 | 30 | * Adds the HTML specific to the mapping service to the output |
33 | | - * |
34 | 31 | */ |
35 | 32 | protected abstract function addSpecificMapHTML(); |
36 | 33 | |
— | — | @@ -51,7 +48,6 @@ |
52 | 49 | |
53 | 50 | /** |
54 | 51 | * Sets the map properties as class fields. |
55 | | - * |
56 | 52 | */ |
57 | 53 | protected function manageMapProperties($mapProperties, $className) { |
58 | 54 | global $egMapsServices; |
— | — | @@ -67,7 +63,6 @@ |
68 | 64 | } |
69 | 65 | } |
70 | 66 | |
71 | | - // TODO: refactor down - not every mapping feature/service should support a controls parameter |
72 | 67 | MapsMapper::enforceArrayValues($this->controls); |
73 | 68 | |
74 | 69 | MapsUtils::makeMapSizeValid($this->width, $this->height); |
— | — | @@ -75,7 +70,6 @@ |
76 | 71 | |
77 | 72 | /** |
78 | 73 | * Sets the $mapName field, using the $elementNamePrefix and $elementNr. |
79 | | - * |
80 | 74 | */ |
81 | 75 | protected function setMapName() { |
82 | 76 | $this->mapName = $this->elementNamePrefix.'_'.$this->elementNr; |
Index: trunk/extensions/Maps/MapUtilityFunctions.js |
— | — | @@ -9,26 +9,11 @@ |
10 | 10 | * @author Jeroen De Dauw |
11 | 11 | */ |
12 | 12 | |
13 | | -/* |
14 | | -function addLoadEvent(func) { |
15 | | - var oldonload = window.onload; |
16 | | - if (typeof oldonload == 'function') { |
17 | | - window.onload = function() { |
18 | | - oldonload(); |
19 | | - func(); |
20 | | - }; |
21 | | - } |
22 | | - else { |
23 | | - window.onload = func; |
24 | | - } |
25 | | -} |
26 | | -*/ |
27 | | - |
28 | 13 | function convertLatToDMS (val) { |
29 | | - return Math.abs(val) + "° " + ( val < 0 ? "S" : "N" ); |
| 14 | + return Math.abs(val) + "� " + ( val < 0 ? "S" : "N" ); |
30 | 15 | } |
31 | 16 | |
32 | 17 | function convertLngToDMS (val) { |
33 | | - return Math.abs(val) + "° " + ( val < 0 ? "W" : "E" ); |
| 18 | + return Math.abs(val) + "� " + ( val < 0 ? "W" : "E" ); |
34 | 19 | |
35 | 20 | } |
\ No newline at end of file |
Index: trunk/extensions/Maps/Maps_Settings.php |
— | — | @@ -64,11 +64,11 @@ |
65 | 65 | include_once $egMapsIP . '/GoogleMaps/Maps_GoogleMaps.php'; // Google Maps |
66 | 66 | include_once $egMapsIP . '/OpenLayers/Maps_OpenLayers.php'; // OpenLayers |
67 | 67 | include_once $egMapsIP . '/YahooMaps/Maps_YahooMaps.php'; // Yahoo! Maps |
68 | | -//include_once $egMapsIP . '/OpenStreetMaps/Maps_OSM.php'; // OpenLayers optimized for OSM |
| 68 | +include_once $egMapsIP . '/OpenStreetMaps/Maps_OSM.php'; // OpenLayers optimized for OSM |
69 | 69 | |
70 | 70 | # Array of String. Array containing all the mapping services that will be made available to the user. |
71 | 71 | # Currently Maps provides the following services: googlemaps, yahoomaps, openlayers |
72 | | -$egMapsAvailableServices = array('googlemaps', 'yahoomaps', 'openlayers'/*, 'osm'*/); |
| 72 | +$egMapsAvailableServices = array('googlemaps', 'yahoomaps', 'openlayers', 'osm'); |
73 | 73 | |
74 | 74 | # String. The default mapping service, which will be used when no default service is prsent in the |
75 | 75 | # $egMapsDefaultServices array for a certain feature. A service that supports all features is recommended. |
— | — | @@ -203,9 +203,8 @@ |
204 | 204 | $egMapsOpenLayersZoom = 13; |
205 | 205 | |
206 | 206 | # Array of String. The default controls for Open Layers. This value will only be used when the user does not provide one. |
207 | | -# Available values: layerswitcher, mouseposition, panzoom, panzoombar, scaleline, navigation, keyboarddefaults, overviewmap, permalink |
208 | | -# Note: panzoom and panzoombar can NOT be used together |
209 | | -$egMapsOLControls = array('layerswitcher', 'mouseposition', 'panzoombar', 'scaleline', 'navigation'); |
| 207 | +# Available values: layerswitcher, mouseposition, autopanzoom, panzoom, panzoombar, scaleline, navigation, keyboarddefaults, overviewmap, permalink |
| 208 | +$egMapsOLControls = array('layerswitcher', 'mouseposition', 'autopanzoom', 'scaleline', 'navigation'); |
210 | 209 | |
211 | 210 | # Array of String. The default layers for Open Layers. This value will only be used when the user does not provide one. |
212 | 211 | # Available values: google, bing, yahoo, openlayers, nasa |
— | — | @@ -220,3 +219,7 @@ |
221 | 220 | |
222 | 221 | # Integer. The default zoom of a map. This value will only be used when the user does not provide one. |
223 | 222 | $egMapsOSMZoom = 13; |
| 223 | + |
| 224 | +# Array of String. The default controls for OSM maps. This value will only be used when the user does not provide one. |
| 225 | +# Available values: layerswitcher, mouseposition, autopanzoom, panzoom, panzoombar, scaleline, navigation, keyboarddefaults, overviewmap, permalink |
| 226 | +$egMapsOSMControls = array('layerswitcher', 'mouseposition', 'autopanzoom', 'scaleline', 'navigation'); |
\ No newline at end of file |
Index: trunk/extensions/Maps/Maps_Utils.php |
— | — | @@ -126,7 +126,7 @@ |
127 | 127 | */ |
128 | 128 | public static function makeMapSizeValid(&$width, &$height) { |
129 | 129 | global $egMapsSizeRestrictions; |
130 | | - |
| 130 | + |
131 | 131 | if ($width < $egMapsSizeRestrictions['width'][0]) { |
132 | 132 | $width = $egMapsSizeRestrictions['width'][0]; |
133 | 133 | } |
— | — | @@ -134,11 +134,11 @@ |
135 | 135 | $width = $egMapsSizeRestrictions['width'][1]; |
136 | 136 | } |
137 | 137 | |
138 | | - if ($width < $egMapsSizeRestrictions['height'][0]) { |
139 | | - $width = $egMapsSizeRestrictions['height'][0]; |
| 138 | + if ($height < $egMapsSizeRestrictions['height'][0]) { |
| 139 | + $height = $egMapsSizeRestrictions['height'][0]; |
140 | 140 | } |
141 | | - else if($width > $egMapsSizeRestrictions['height'][1]) { |
142 | | - $width = $egMapsSizeRestrictions['height'][1]; |
| 141 | + else if($height > $egMapsSizeRestrictions['height'][1]) { |
| 142 | + $height = $egMapsSizeRestrictions['height'][1]; |
143 | 143 | } |
144 | 144 | } |
145 | 145 | |
Index: trunk/extensions/Maps/OpenStreetMaps/Maps_OSMDispMap.php |
— | — | @@ -50,19 +50,22 @@ |
51 | 51 | public function addSpecificMapHTML() { |
52 | 52 | global $wgJsMimeType; |
53 | 53 | |
| 54 | + $controlItems = MapsOSMUtils::createControlsString($this->controls); |
| 55 | + |
54 | 56 | $this->output .= <<<EOT |
55 | 57 | <script type='$wgJsMimeType'>slippymaps['$this->mapName'] = new slippymap_map('$this->mapName', { |
56 | 58 | mode: 'osm-wm', |
57 | 59 | layer: 'osm-like', |
58 | | - locale: 'en', |
| 60 | + locale: 'en', |
59 | 61 | lat: $this->centre_lat, |
60 | 62 | lon: $this->centre_lon, |
61 | 63 | zoom: $this->zoom, |
62 | 64 | width: $this->width, |
63 | 65 | height: $this->height, |
64 | | - marker: 0 |
| 66 | + markers: [], |
| 67 | + controls: [$controlItems] |
65 | 68 | });</script> |
66 | | - |
| 69 | + |
67 | 70 | <!-- map div --> |
68 | 71 | <div id='$this->mapName' class='map' style='width:{$this->width}px; height:{$this->height}px;'> |
69 | 72 | <script type='$wgJsMimeType'>slippymaps['$this->mapName'].init();</script> |
Index: trunk/extensions/Maps/OpenStreetMaps/OSMFunctions.js |
— | — | @@ -52,7 +52,30 @@ |
53 | 53 | slippymaps[keyName].init(); |
54 | 54 | } |
55 | 55 | } |
| 56 | + |
| 57 | +/** |
| 58 | + * Gets a valid control name (with excat lower and upper case letters), |
| 59 | + * or returns false when the control is not allowed. |
| 60 | + */ |
| 61 | +function getValidControlName(control) { |
| 62 | + var OLControls = ['ArgParser', 'Attribution', 'Button', 'DragFeature', 'DragPan', |
| 63 | + 'DrawFeature', 'EditingToolbar', 'GetFeature', 'KeyboardDefaults', 'LayerSwitcher', |
| 64 | + 'Measure', 'ModifyFeature', 'MouseDefaults', 'MousePosition', 'MouseToolbar', |
| 65 | + 'Navigation', 'NavigationHistory', 'NavToolbar', 'OverviewMap', 'Pan', |
| 66 | + 'Panel', 'PanPanel', 'PanZoom', 'PanZoomBar', 'Permalink', |
| 67 | + 'Scale', 'ScaleLine', 'SelectFeature', 'Snapping', 'Split', |
| 68 | + 'WMSGetFeatureInfo', 'ZoomBox', 'ZoomIn', 'ZoomOut', 'ZoomPanel', |
| 69 | + 'ZoomToMaxExtent']; |
56 | 70 | |
| 71 | + for (i in OLControls) { |
| 72 | + if (control == OLControls[i].toLowerCase()) { |
| 73 | + return OLControls[i]; |
| 74 | + } |
| 75 | + } |
| 76 | + |
| 77 | + return false; |
| 78 | +} |
| 79 | + |
57 | 80 | function slippymap_map(mapId, mapParams) { |
58 | 81 | var self = this; |
59 | 82 | this.mapId = mapId; |
— | — | @@ -75,17 +98,29 @@ |
76 | 99 | ]); |
77 | 100 | */ |
78 | 101 | |
| 102 | + /* |
79 | 103 | this.mapOptions = { controls: [ new OpenLayers.Control.Navigation(), |
80 | 104 | new OpenLayers.Control.ArgParser(), |
81 | 105 | new OpenLayers.Control.Attribution(), |
82 | | - /* buttonsPanel */ ] |
| 106 | + // buttonsPanel |
| 107 | + ] |
83 | 108 | }; |
| 109 | + */ |
84 | 110 | |
85 | | - /* Add the zoom bar control, except if the map is only little */ |
86 | | - if (this.height > 320) |
87 | | - this.mapOptions.controls.push(new OpenLayers.Control.PanZoomBar()); |
88 | | - else if (this.height > 140) |
89 | | - this.mapOptions.controls.push(new OpenLayers.Control.PanZoom()); |
| 111 | + // Add the controls |
| 112 | + this.mapOptions = {controls: []}; |
| 113 | + |
| 114 | + for (i in this.controls) { |
| 115 | + if (this.controls[i].toLowerCase() == 'autopanzoom') { |
| 116 | + if (this.height > 140) this.controls[i] = this.height > 320 ? 'panzoombar' : 'panzoom'; |
| 117 | + } |
| 118 | + |
| 119 | + control = getValidControlName(this.controls[i]); |
| 120 | + |
| 121 | + if (control) { |
| 122 | + eval(' this.mapOptions.controls.push( new OpenLayers.Control.' + control + '() ); '); |
| 123 | + } |
| 124 | + } |
90 | 125 | } |
91 | 126 | |
92 | 127 | slippymap_map.prototype.init = function() { |
— | — | @@ -96,12 +131,36 @@ |
97 | 132 | |
98 | 133 | this.map = this.osm_create(this.mapId, this.lon, this.lat, this.zoom); |
99 | 134 | |
100 | | - if (this.marker) { |
101 | | - var markers = new OpenLayers.Layer.Markers( "Markers" ); |
102 | | - this.map.addLayer(markers); |
103 | | - var icon = OpenLayers.Marker.defaultIcon(); |
104 | | - markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(this.lon, this.lat).transform(new OpenLayers.Projection('EPSG:4326'), this.map.getProjectionObject()), icon)); |
| 135 | + var centerIsSet = this.lon != null && this.lat != null; |
| 136 | + |
| 137 | + var bounds = null; |
| 138 | + |
| 139 | + if (this.markers.length > 0) { |
| 140 | + var markerLayer = new OpenLayers.Layer.Markers('Markers'); |
| 141 | + markerLayer.id= 'markerLayer'; |
| 142 | + this.map.addLayer(markerLayer); |
| 143 | + |
| 144 | + if (this.markers.length > 1 && (!centerIsSet || this.zoom == null)) { |
| 145 | + bounds = new OpenLayers.Bounds(); |
| 146 | + } |
| 147 | + |
| 148 | + for (i in this.markers) { |
| 149 | + this.markers[i].lonlat.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913")); |
| 150 | + if (bounds != null) bounds.extend(this.markers[i].lonlat); // Extend the bounds when no center is set |
| 151 | + markerLayer.addMarker(getOSMMarker(markerLayer, this.markers[i], this.map.getProjectionObject())); // Create and add the marker |
| 152 | + } |
| 153 | + |
105 | 154 | } |
| 155 | + |
| 156 | + if (bounds != null) map.zoomToExtent(bounds); // If a bounds object has been created, use it to set the zoom and center |
| 157 | + |
| 158 | + if (centerIsSet) { // When the center is provided, set it |
| 159 | + var centre = new OpenLayers.LonLat(this.lon, this.lat); |
| 160 | + centre.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913")); |
| 161 | + this.map.setCenter(centre); |
| 162 | + } |
| 163 | + |
| 164 | + if (this.zoom != null) this.map.zoomTo(this.zoom); // When the zoom is provided, set it |
106 | 165 | } |
107 | 166 | |
108 | 167 | slippymap_map.prototype.osm_create = function(mapId, lon, lat, zoom) { |
— | — | @@ -109,7 +168,7 @@ |
110 | 169 | var map = new OpenLayers.Map(mapId, this.mapOptions /* all provided for by OSM.js */); |
111 | 170 | |
112 | 171 | if (this.layer == 'osm-like') { |
113 | | - osmLayer = new OpenLayers.Layer.OSM("meh", 'http://cassini.toolserver.org/tiles/osm-like/' + this.locale + '/${z}/${x}/${y}.png'); |
| 172 | + osmLayer = new OpenLayers.Layer.OSM("OpenStreetMaps", 'http://cassini.toolserver.org/tiles/osm-like/' + this.locale + '/${z}/${x}/${y}.png'); |
114 | 173 | } |
115 | 174 | |
116 | 175 | map.addLayers([osmLayer]); |
— | — | @@ -132,5 +191,47 @@ |
133 | 192 | ); |
134 | 193 | } |
135 | 194 | |
| 195 | +function getOSMMarkerData(lon, lat, title, label, icon) { |
| 196 | + lonLat = new OpenLayers.LonLat(lon, lat); |
| 197 | + return { |
| 198 | + lonlat: lonLat, |
| 199 | + title: title, |
| 200 | + label: label, |
| 201 | + icon: icon |
| 202 | + }; |
| 203 | +} |
136 | 204 | |
| 205 | +function getOSMMarker(markerLayer, markerData, projectionObject) { |
| 206 | + var marker; |
| 207 | + |
| 208 | + if (markerData.icon != '') { |
| 209 | + marker = new OpenLayers.Marker(markerData.lonlat, new OpenLayers.Icon(markerData.icon)); |
| 210 | + } else { |
| 211 | + marker = new OpenLayers.Marker(markerData.lonlat); |
| 212 | + } |
| 213 | + |
| 214 | + if (markerData.title.length + markerData.label.length > 0 ) { |
| 215 | + |
| 216 | + // This is the handler for the mousedown event on the marker, and displays the popup |
| 217 | + marker.events.register('mousedown', marker, |
| 218 | + function(evt) { |
| 219 | + var popup = new OpenLayers.Feature(markerLayer, markerData.lonlat).createPopup(true); |
| 220 | + |
| 221 | + if (markerData.title.length > 0 && markerData.label.length > 0) { // Add the title and label to the popup text |
| 222 | + popup.setContentHTML('<b>' + markerData.title + "</b><hr />" + markerData.label); |
| 223 | + } |
| 224 | + else { |
| 225 | + popup.setContentHTML(markerData.title + markerData.label); |
| 226 | + } |
| 227 | + |
| 228 | + popup.setOpacity(0.85); |
| 229 | + markerLayer.map.addPopup(popup); |
| 230 | + OpenLayers.Event.stop(evt); // Stop the event |
| 231 | + } |
| 232 | + ); |
| 233 | + |
| 234 | + } |
| 235 | + |
| 236 | + return marker; |
| 237 | +} |
137 | 238 | |
Index: trunk/extensions/Maps/OpenStreetMaps/Maps_OSMUtils.php |
— | — | @@ -80,13 +80,11 @@ |
81 | 81 | public static function getDefaultParams() { |
82 | 82 | return array |
83 | 83 | ( |
84 | | - 'layers' => array(), |
85 | | - 'baselayer' => '' |
86 | 84 | ); |
87 | 85 | } |
88 | 86 | |
89 | 87 | /** |
90 | | - * If this is the first open layers map on the page, load the API, styles and extra JS functions |
| 88 | + * If this is the first OSM map on the page, load the OpenLayers API, OSM styles and extra JS functions |
91 | 89 | * |
92 | 90 | * @param string $output |
93 | 91 | */ |
— | — | @@ -102,6 +100,17 @@ |
103 | 101 | <script type='$wgJsMimeType' src='$egMapsScriptPath/OpenStreetMaps/OSMFunctions.js?$wgStyleVersion'></script> |
104 | 102 | <script type='$wgJsMimeType'>slippymaps = Array();</script>\n"; |
105 | 103 | } |
| 104 | + } |
| 105 | + |
| 106 | + /** |
| 107 | + * Build up a csv string with the controls, to be outputted as a JS array |
| 108 | + * |
| 109 | + * @param array $controls |
| 110 | + * @return csv string |
| 111 | + */ |
| 112 | + public static function createControlsString(array $controls) { |
| 113 | + global $egMapsOSMControls; |
| 114 | + return MapsMapper::createJSItemsString($controls, $egMapsOSMControls); |
106 | 115 | } |
107 | 116 | |
108 | 117 | } |
Index: trunk/extensions/Maps/OpenStreetMaps/Maps_OSMDispPoint.php |
— | — | @@ -64,17 +64,34 @@ |
65 | 65 | $label = str_replace("'", "\'", $label); |
66 | 66 | |
67 | 67 | $icon = array_key_exists('icon', $markerData) ? $markerData['icon'] : ''; |
68 | | - $markerItems[] = "getOLMarkerData($lon, $lat, '$title', '$label', '$icon')"; |
| 68 | + $markerItems[] = "getOSMMarkerData($lon, $lat, '$title', '$label', '$icon')"; |
69 | 69 | } |
70 | 70 | |
71 | 71 | $markersString = implode(',', $markerItems); |
72 | 72 | |
73 | | - $this->output .= "<div id='$this->mapName' style='width: {$this->width}px; height: {$this->height}px; background-color: #cccccc;'></div> |
74 | | - <script type='$wgJsMimeType'> /*<![CDATA[*/ |
75 | | - addOnloadHook( |
76 | | - initOpenLayer('$this->mapName', $this->centre_lon, $this->centre_lat, $this->zoom, [$layerItems], [$controlItems],[$markersString]) |
77 | | - ); |
78 | | - /*]]>*/ </script>"; |
| 73 | + $controlItems = MapsOSMUtils::createControlsString($this->controls); |
| 74 | + |
| 75 | + $this->output .= <<<EOT |
| 76 | + <script type='$wgJsMimeType'>slippymaps['$this->mapName'] = new slippymap_map('$this->mapName', { |
| 77 | + mode: 'osm-wm', |
| 78 | + layer: 'osm-like', |
| 79 | + locale: 'en', |
| 80 | + lat: $this->centre_lat, |
| 81 | + lon: $this->centre_lon, |
| 82 | + zoom: $this->zoom, |
| 83 | + width: $this->width, |
| 84 | + height: $this->height, |
| 85 | + markers: [$markersString], |
| 86 | + controls: [$controlItems] |
| 87 | + |
| 88 | + });</script> |
| 89 | + |
| 90 | + <!-- map div --> |
| 91 | + <div id='$this->mapName' class='map' style='width:{$this->width}px; height:{$this->height}px;'> |
| 92 | + <script type='$wgJsMimeType'>slippymaps['$this->mapName'].init();</script> |
| 93 | + <!-- /map div --> |
| 94 | + </div> |
| 95 | +EOT; |
79 | 96 | } |
80 | 97 | |
81 | 98 | } |
\ No newline at end of file |