Index: trunk/extensions/SlippyMap/OpenStreetMap.js |
— | — | @@ -143,9 +143,9 @@ |
144 | 144 | */ |
145 | 145 | initialize: function(name, options) { |
146 | 146 | var url = [ |
147 | | - "http://a.tah.openstreetmap.org/Tiles/tile.php/", |
148 | | - "http://b.tah.openstreetmap.org/Tiles/tile.php/", |
149 | | - "http://c.tah.openstreetmap.org/Tiles/tile.php/" |
| 147 | + "http://a.tah.openstreetmap.org/Tiles/tile/", |
| 148 | + "http://b.tah.openstreetmap.org/Tiles/tile/", |
| 149 | + "http://c.tah.openstreetmap.org/Tiles/tile/" |
150 | 150 | ]; |
151 | 151 | options = OpenLayers.Util.extend({ numZoomLevels: 18 }, options); |
152 | 152 | var newArguments = [name, url, options]; |
— | — | @@ -199,9 +199,9 @@ |
200 | 200 | */ |
201 | 201 | initialize: function(name, options) { |
202 | 202 | var url = [ |
203 | | - "http://d.tah.openstreetmap.org/Tiles/maplint.php/", |
204 | | - "http://e.tah.openstreetmap.org/Tiles/maplint.php/", |
205 | | - "http://f.tah.openstreetmap.org/Tiles/maplint.php/" |
| 203 | + "http://d.tah.openstreetmap.org/Tiles/maplint/", |
| 204 | + "http://e.tah.openstreetmap.org/Tiles/maplint/", |
| 205 | + "http://f.tah.openstreetmap.org/Tiles/maplint/" |
206 | 206 | ]; |
207 | 207 | options = OpenLayers.Util.extend({ numZoomLevels: 18, isBaseLayer: false, visibility: false }, options); |
208 | 208 | var newArguments = [name, url, options]; |
Index: trunk/extensions/SlippyMap/SlippyMap.class.php |
— | — | @@ -63,7 +63,7 @@ |
64 | 64 | $marker = ''; |
65 | 65 | } |
66 | 66 | |
67 | | - $error=""; |
| 67 | + $error=''; |
68 | 68 | |
69 | 69 | //default values (meaning these parameters can be missed out) |
70 | 70 | if ($width=='') $width ='450'; |
— | — | @@ -77,8 +77,8 @@ |
78 | 78 | $marker = ( $marker != '' && $marker != '0' ); |
79 | 79 | |
80 | 80 | //trim off the 'px' on the end of pixel measurement numbers (ignore if present) |
81 | | - if (substr($width,-2)=='px') $width = substr($width,0,-2); |
82 | | - if (substr($height,-2)=='px') $height = substr($height,0,-2); |
| 81 | + if (substr($width,-2)=='px') $width = (int) substr($width,0,-2); |
| 82 | + if (substr($height,-2)=='px') $height = (int) substr($height,0,-2); |
83 | 83 | |
84 | 84 | //Check required parameters values are provided |
85 | 85 | if ( $lat=='' ) $error .= wfMsg( 'slippymap_latmissing' ); |
— | — | @@ -155,34 +155,17 @@ |
156 | 156 | // page loading and rendering dramatically |
157 | 157 | $output .= 'addOnloadHook( function() { ' . |
158 | 158 | ' var sc = document.createElement("script");' . |
159 | | - ' sc.src = "http://openlayers.org/api/OpenLayers.js";' . |
| 159 | + ' sc.src = "http://www.openlayers.org/api/OpenLayers.js";' . |
160 | 160 | ' document.body.appendChild( sc );' . |
161 | 161 | ' var sc = document.createElement("script");' . |
162 | 162 | ' sc.src = "http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/SlippyMap/OpenStreetMap.js?view=co&' . $wgSlippyMapVersion . '";'. |
163 | 163 | ' document.body.appendChild( sc );' . |
164 | 164 | '} );'; |
165 | 165 | |
166 | | - $output .= "var lon= $lon; var lat= $lat; var zoom= $zoom; var lonLat;"; |
| 166 | + $output .= "var lon= ${lon}; var lat= ${lat}; var zoom= ${zoom}; var lonLat;"; |
167 | 167 | |
168 | 168 | $output .= 'var map; '; |
169 | 169 | |
170 | | - $output .= 'function lonLatToMercator(ll) { '; |
171 | | - $output .= ' var lon = ll.lon * 20037508.34 / 180; '; |
172 | | - $output .= ' var lat = Math.log (Math.tan ((90 + ll.lat) * Math.PI / 360)) / (Math.PI / 180); '; |
173 | | - $output .= ' lat = lat * 20037508.34 / 180; '; |
174 | | - |
175 | | - $output .= ' return new OpenLayers.LonLat(lon, lat); '; |
176 | | - $output .= '} '; |
177 | | - |
178 | | - $output .= 'function MercatorToLonLat(ll) { '; |
179 | | - $output .= ' var lon = ll.lon / 20037508.34 * 180; '; |
180 | | - $output .= ' var lat = ll.lat / 20037508.34 * 180 * ( Math.PI / 180 ); '; |
181 | | - $output .= ' lat = ( Math.pow(Math.E, lat) - Math.pow(Math.E, -lat) ) / 2; '; |
182 | | - $output .= ' lat = Math.atan( lat ); '; |
183 | | - $output .= ' lat = lat * 180 / Math.PI;'; |
184 | | - $output .= ' return new OpenLayers.LonLat(lon, lat); '; |
185 | | - $output .= ' } '; |
186 | | - |
187 | 170 | $output .= 'addOnloadHook( slippymap_init ); '; |
188 | 171 | |
189 | 172 | $output .= 'function slippymap_init() { '; |
— | — | @@ -201,13 +184,13 @@ |
202 | 185 | |
203 | 186 | $output .= ' new OpenLayers.Control.Attribution()], '; |
204 | 187 | $output .= ' maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34), '; |
205 | | - $output .= " maxResolution:156543.0399, units:'meters', projection: \"EPSG:900913\"} ); "; |
| 188 | + $output .= ' maxResolution:156543.0399, units:\'meters\', projection: "EPSG:900913"} ); '; |
206 | 189 | |
207 | | - $output .= " layer = new " . $layerObjectDef; |
| 190 | + $output .= ' layer = new ' . $layerObjectDef; |
208 | 191 | |
209 | | - $output .= " map.addLayer(layer); "; |
| 192 | + $output .= ' map.addLayer(layer); '; |
210 | 193 | |
211 | | - $output .= " lonLat = lonLatToMercator(new OpenLayers.LonLat(lon, lat)); "; |
| 194 | + $output .= ' lonLat = new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()); '; |
212 | 195 | |
213 | 196 | if ( $marker ) { |
214 | 197 | $output .= 'var markers = new OpenLayers.Layer.Markers( "Markers" ); ' . |
— | — | @@ -218,11 +201,12 @@ |
219 | 202 | ' markers.addMarker(new OpenLayers.Marker( lonLat,icon)); '; |
220 | 203 | } |
221 | 204 | |
222 | | - $output .= " map.setCenter (lonLat, zoom); "; |
223 | | - $output .= "} "; |
| 205 | + $output .= ' map.setCenter (lonLat, zoom); '; |
| 206 | + $output .= '} '; |
224 | 207 | |
225 | 208 | $output .= 'function slippymap_getWikicode() {'; |
226 | | - $output .= ' LL = MercatorToLonLat(map.getCenter()); Z = map.getZoom();'; |
| 209 | + $output .= ' LL = map.getCenter().transform(map.getProjectionObject(), new OpenLayers.Projection("EPSG:4326"));'; |
| 210 | + $output .= ' Z = map.getZoom(); '; |
227 | 211 | $output .= ' size = map.getSize();'; |
228 | 212 | |
229 | 213 | $output .= ' prompt( "' . wfMsg('slippymap_code') .'", "<slippymap h="+size.h+" w="+size.w+" z="+Z+" lat="+LL.lat+" lon="+LL.lon+" layer=mapnik marker=1></slippymap>" ); '; |
— | — | @@ -233,9 +217,9 @@ |
234 | 218 | $output .= '<div class="map">'; |
235 | 219 | $output .= "<div style=\"width: {$width}px; height:{$height}px; border-style:solid; border-width:1px; border-color:lightgrey;\" id=\"map\">"; |
236 | 220 | $output .= "<noscript><a href=\"http://www.openstreetmap.org/?lat=$lat&lon=$lon&zoom=$zoom\" title=\"See this map on OpenStreetMap.org\" style=\"text-decoration:none\">"; |
237 | | - $output .= "<img src=\"".$wgMapOfServiceUrl."lat=$lat&long=$lon&z=$zoom&w=$width&h=$height&format=jpeg\" width=\"$width\" height=\"$height\" border=\"0\"><br/>"; |
238 | | - $output .= '<span style="font-size:60%; background-color:white; position:relative; top:-15px; ">OpenStreetMap - CC-BY-SA-2.0</span>'; |
239 | | - $output .= '</a></noscript></div><div id="postmap"><input type="button" value="' . wfMsg('slippymap_resetview') . '" onmousedown="map.setCenter(lonLat, zoom);" /><input type="button" value="' . wfMsg('slippymap_button_code') . '" onmousedown="slippymap_getWikicode();" /></div></div>'; |
| 221 | + $output .= "<img src=\"".$wgMapOfServiceUrl."lat=${lat}&long=${lon}&z=${zoom}&w=${width}&h=${height}&format=jpeg\" width=\"${width}\" height=\"${height}\" border=\"0\"><br/>"; |
| 222 | + $output .= '</a></noscript>'; |
| 223 | + $output .= '</div><div id="postmap"><input type="button" value="' . wfMsg('slippymap_resetview') . '" onmousedown="map.setCenter(lonLat, zoom);" /><input type="button" value="' . wfMsg('slippymap_button_code') . '" onmousedown="slippymap_getWikicode();" /></div></div>'; |
240 | 224 | } |
241 | 225 | return $output; |
242 | 226 | } |