Widget:OpenStreetMap: Difference between revisions
Jump to navigation
Jump to search
Added features for route mapping |
Trying to disable mouse wheel zoom, because this causes problems when scrolling wiki pages |
||
Line 82: | Line 82: | ||
var mapUnits = '<!--{$units|escape:'quotes'|default:'degrees'}-->'; | var mapUnits = '<!--{$units|escape:'quotes'|default:'degrees'}-->'; | ||
var epsg4326 = new OpenLayers.Projection('EPSG:4326'); | var epsg4326 = new OpenLayers.Projection('EPSG:4326'); | ||
var movemap = new OpenLayers.Control.Navigation({ | |||
> 'zoomWheelEnabled': false}); | |||
movemap.disableZoomWheel(); | |||
// add the openstreetmap layer | // add the openstreetmap layer | ||
Line 87: | Line 93: | ||
units: mapUnits, | units: mapUnits, | ||
controls: [ | controls: [ | ||
new OpenLayers.Control.Navigation(), | new OpenLayers.Control.Navigation({'zoomWheelEnabled': false}), | ||
new OpenLayers.Control.ArgParser(), | new OpenLayers.Control.ArgParser(), | ||
new OpenLayers.Control.PanZoomBar(), | new OpenLayers.Control.PanZoomBar(), | ||
Line 106: | Line 112: | ||
map.setCenter(centerPt, zoom); | map.setCenter(centerPt, zoom); | ||
// make sure mouse wheel zooming is disabled | |||
controls = map.getControlsByClass('OpenLayers.Control.Navigation'); | |||
for(var i = 0; i < controls.length; ++i) | |||
controls.disableZoomWheel(); | |||
<!--{if $showmarker eq 'true'}--> | <!--{if $showmarker eq 'true'}--> |
Revision as of 05:53, 9 April 2012
This widget allows you to embed OpenStreetMap in a wiki page.
Using this widget
You can insert a map with the following wiki code:
{{#widget:OpenStreetMap|lat=52.94762|lon=-1.1467897|zoom=16}}
Parameters
- width
- Width of the embedded map (default 400px).
- height
- Height of the embedded map (default 400px).
- lat
- The x-coordinate for the centre of the view.
- lon
- The y-coordinate for the centre of the view.
- units
- The type of map units used for the coordinates (defaults to 'degrees').
- zoom
- The zoom level (default 15).
- showmarker
- Adds a visual marker to the center of the map (default false).
- showmouseposition
- Displays the position of the mouse cursor in map coordinates.
Points of interest
- poifile
- Specifies the url of a file containing points of interest (POI) that should be overlaid on the map. See the file format description in [1]. Note: there is a bug that causes the last line of the poi file to be ignored; a workaround is to add a trailing line with a single '.' character.
- poititle
- The title of the POI layer (default 'Points of interest').
Storing points of interest on a wiki page
Instead of uploading a file you can add the points of interest to a wiki page and link to the raw page text, for example:
{{#widget:OpenStreetMap|...|poifile={{fullurl:Wiki page title|action=raw&templates=expand&ctype=text/plain}} }}
Note: If you change the contents of that wiki page you must purge the page cache (for each page that uses it in a map) before you can see the change.
Overlay a path
You can draw paths using connected line segments. This is useful for showing routes. Each path should have a unique name. For the parameters described below the placeholder '<id>' should be replaced with the name of the path.
- path.<id>.title
- Gives a title to the overlay (default "Route")
- path.<id>.point.lat
- Adds the latitude of a point to the path. You can specify this parameter many times to add all of the points to the path.
- path.<id>.point.lon
- Adds the longitude of a point to the path. You must specify this parameter the same number of times as the 'lat' parameter.
- path.<id>.colour
- Sets the colour to draw the path (default "#0033cc")
- path.<id>.opacity
- Sets the path opacity, in the range [0-1] (default 1)
- path.<id>.width
- Sets the line width (default 4)
Javascript alternatives
These alternatives can be used to cater for browsers that do not support javascript.
- alt_image
- The url of an image to represent the map.
- alt_text
- A description of the alt_image.