To insert a map into your page you need to add a shortcode. In its simplest form, you can just add
[osmap] to your page, as shown on the installation page. If your API key is set up correctly this will display a map with the default height and zoom level, centred on OS headquarters in Southampton. It’s a quick test, but not very useful.
There are four ways to specify what area your map is showing:
- Specify the centre point and zoom level. This will show a map with no markers. This shows a specific map scale, e.g. 1:50,000 but makes no guarantee about what area will be shown on screen due to differing screen sizes.
[osmap centre="53.068567,-4.076072" zoom=7]
- Specify two diagonally opposite corners of the area you want to be displayed. This differs from the first method in that the zoom level will adapt to fit the required area to the screen. On a small screen it will need to use a more zoomed out scale.
- Specify one or more markers to display on the map. For multiple markers the map will automatically zoom and centre to show all markers, unless you give an explicit centre point to override this behaviour.
[osmap markers="SH6099054380;Snowdon|SH6564658285!red;Glyder Fach"]
- Specify a GPX or KML track file to load. The map will automatically zoom and centre to show the entire track.
Markers and centre points can be specified either as a latitude, longitude pair or as an OS 6, 8 or 10 figure grid reference. OS grid references must include the two letter prefix, not just the numbers.
Note that you can display a GPX file and markers on the same map. The auto-fit will accommodate them all. You can also override the auto fit by also specifying zoom/centre or map extent.
Simple Shortcode Attributes
Note that the order in which you list attributes is unimportant.
height=400 Sets the height of the map in pixels, overriding the default on the settings page
width=600 Sets the width of the map in pixels, overriding the default on the settings page
zoom=5 Sets the initial map zoom level using the zoom selection value described above in Map Zoom.
centre=SD8128299116 Sets the map centre point, to override the default centre point, or if not using markers or track files. This can be an OS grid reference or a comma-separated latitude/longitude pair.
extent="NY200200|NY260220" Sets the map area to be covered. This requires two points, diagonally opposite corner s of the area you want to be displayed.
Like any other shortcode in WordPress, you can use quotes around shortcode attributes if the attribute is anything other than a single word or number. But be careful that you’re using plain old ASCII straight quotes like ” or ‘. Don’t use “curly quotes” as they won’t work and you may just get a blank map, or you may get an error message to say that the position is not valid.
Map showing Landranger data
This map of Ambleside is the one OS uses on their own demo pages. You can zoom in to show street level detail, including house numbers. This map is using the defaults from the settings page. Height is set to 400 pixels and zoom to 7. All I have provided here is the centre point as an OS grid reference. In this case it’s a 6-figure reference but you can use 6, 8 or 10. You can also use latitude/longitude if you prefer.
Map with three markers, auto-zoomed
This shows how maps with multiple markers will automatically scale to show all markers. I’ve used a different colour for each of the three peaks.
[osmap markers="SH609543;Snowdon|SH656582!red;Glyder Fach|SH705546!green;Carnedd Moel Siabod"]
Overriding the default settings
If you want to override the defaults for a particular map, just specify the values in the attributes. Here I’ve made the map taller and increased the zoom level.
[osmap centre="SH6099054380" height="600" zoom="9"]« Settings Page Up Adding Markers »