Widget:OpenStreetMap: Unterschied zwischen den Versionen
Aus Stratum 0
K (noinclude-fail) |
(re-align & beautify attribution) |
||
(4 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 10: | Zeile 10: | ||
* '''lat''', '''lon''' - latitude and longitude | * '''lat''', '''lon''' - latitude and longitude | ||
* '''zoom''' - zoom, ranging from 1 (overview) to 18 (detailed) | * '''zoom''' - zoom, ranging from 1 (overview) to 18 (detailed) | ||
+ | * '''height''', '''width''': height and width of the map widget. Default height is 250px, default width is auto. | ||
== Sample result == | == Sample result == | ||
{{#widget:OpenStreetMap|lat=52.2785658|lon=10.5211247|zoom=16}} | {{#widget:OpenStreetMap|lat=52.2785658|lon=10.5211247|zoom=16}} | ||
− | </noinclude><includeonly><div id="mapdiv"></div> | + | </noinclude><includeonly><div id="mapdiv" style="height:<!--{$height|escape:'html'|default:'300px'}-->; width:<!--{$width|escape:'html'|default:'auto'}-->"></div> |
− | <script src=" | + | <script src="/openlayers/OpenLayers.js"></script> |
<script> | <script> | ||
map = new OpenLayers.Map("mapdiv"); | map = new OpenLayers.Map("mapdiv"); | ||
− | map.addLayer(new OpenLayers.Layer.OSM()); | + | map.addLayer(new OpenLayers.Layer.OSM("OpenStreetMap", [ |
+ | "https://c.tile.openstreetmap.org/${z}/${x}/${y}.png", | ||
+ | "https://b.tile.openstreetmap.org/${z}/${x}/${y}.png", | ||
+ | "https://a.tile.openstreetmap.org/${z}/${x}/${y}.png" | ||
+ | ])); | ||
var lonLat = new OpenLayers.LonLat(<!--{$lon|validate:float|default:0}-->,<!--{$lat|validate:float|default:0}-->) | var lonLat = new OpenLayers.LonLat(<!--{$lon|validate:float|default:0}-->,<!--{$lat|validate:float|default:0}-->) | ||
.transform( | .transform( | ||
Zeile 27: | Zeile 32: | ||
markers.addMarker(new OpenLayers.Marker(lonLat)); | markers.addMarker(new OpenLayers.Marker(lonLat)); | ||
map.setCenter(lonLat, <!--{$zoom|validate:int|default:15}-->); | map.setCenter(lonLat, <!--{$zoom|validate:int|default:15}-->); | ||
+ | |||
+ | // re-align & beautify attribution | ||
+ | $('.olControlAttribution').css('bottom', '0.5em'). | ||
+ | css('right', '0.5em'). | ||
+ | css('display', 'table'). | ||
+ | css('backgroundColor', 'white'). | ||
+ | css('opacity', '0.8'). | ||
+ | css('padding', '0.4em 0.4em 0.2em 0.4em'). | ||
+ | css('lineHeight', '0.8'). | ||
+ | css('borderRadius', '0.5em'); | ||
</script></includeonly> | </script></includeonly> |
Aktuelle Version vom 4. November 2015, 20:56 Uhr
This widget allows you to add an OpenStreetMap widget to your wiki page.
Using this widget
To insert this widget, use the following code:
{{#widget:OpenStreetMap|lat=<latitude>|lon=<longitude>|zoom=<zoom>}}
Parameters
- lat, lon - latitude and longitude
- zoom - zoom, ranging from 1 (overview) to 18 (detailed)
- height, width: height and width of the map widget. Default height is 250px, default width is auto.