Recent Changes - Search:
Cookbook


Topics


Changed

Visitor's book Site map pmwiki-2.2.98

NZ Topo

NZTopo version 2015-07-01

Summary: Use http://www.topomap.co.nz/ to display an excerpt from a New Zealand map in PmWiki
Version: 2015-07-01
Prerequisites: PmWiki 2.2.59 (PHP 5.5 compatible)
Status: Production
Maintainer: skiwi
Licence: GPL3[1]
Categories: Images Includes PHP55
Users: (view? / edit)
Discussion: NZTopo-Talk?
License: GPL3+

Questions answered by this recipe

How do I display on a PmWiki page part of a topographic map of New Zealand using the official LINZ's 1:50,000 / Topo50 and 1:250,000 / Topo250 maps, as well as 1:25,000 / Topo25 maps for some of the outer islands?

Description

This recipe generates the markup for nztopomap.co.nz's ability to share the map

Installation

  • download 2015-07-01-nztopo.php
  • copy to the /cookbook/ directory as nztopo.php
  • add to config.php the line
    include_once("$FarmD/cookbook/nztopo.php");

Usage

Place the directive, as described below, in your PmWiki page.

You can specify a locale as a decimal WGS84 latitude and longitude (ll), in NZTM coordinates (nzne), as a Topo50 map reference (mapref), or specify a publicly accessible the URL of a gpx or kml file to overlay on the map (kml, gmx).

The scale of the map, but not the image, will automatically resize to the area covered by the kml / gpx data, or you can optionally specify the map zoom factor and the image size (height and width) to control the area of the map shown.

You can specify bounds of an area, by latitude and longitude (llbs), or NZTM coordinates (nzbs). The recipe will resize the map image based on the size of the rectangle defined by the bounds and the zoom scale factor.

You can optionally specify to show a pin marker (pin), and again optionally show a tool tip label for the marker (label).

The recipe provides a page variable {$NZTopoVersion} which contains the current version, and $NZTopo for a (:if enabled NZTopo:) recipe installation check.

Configuration

(:nztopo ll=latitude,longitude

llbs=latitude,longitude;latitude,longitude[;latitude,longitude...]
nzne=northing,easting
nzbs=northing,easting;northing,easting[;northing,easting...]
mapref=mapref
kml="url" gpx="url"
height=pixels width=pixels pin=1 label="string" zoom=number float=left|right clear=both|right|left:)
  • ll= -- centre point of the map as a decimal latitude,longitude
  • llbs= -- decimal latitude longitude bounds: latitude,longitude;latitude,longitude[;latitude,longitude...]
  • nzne= -- centre point of the map as an NZTM northing,easting
  • nzbs= -- NZTM bounds: northing,easting;northing,easting[;northing,easting...]
  • mapref= -- NZ Topo50 grid reference, AAxxxyyy, e.g. BN33991890
  • kml= -- URL to kml/GeoRSS file
  • gpx= -- URL to gpx file

Only one of: ll; llbs; nzne; nzbs; kml; gpx; can be specified

  • height= -- image height in pixels, default is 150
  • width= -- image width in pixels, default is 300
  • float= -- float image to left or right
  • clear= -- clear image to left, right, or both
  • raw= -- raw=1 for DropBox files
  • pin= -- show pin (1)
  • label= -- tool tip label for pin
  • zoom= -- scale factor for map (5 to 15), zoom is ignored when bounds parameters are supplied

config.php settings

You can change the default zoom factor by using the variable $NZTpopXZoom in config.php. For example

$NZTopoZoom = 10; # set default zoom factor for NZTopo directive

By default clicking on the maps opens a full screen map in a new browser tab. You can change this as follows

$NZTopoNewwin = 0; # set open in new window flag for NZTopo directive

Notes

For the bounds llbs and nzbs parameters only two coordinates need to be supplied, but they take any number of coordinates. If a user had a bunch of coordinates they're interested in they don't need to manually calculate the two corner points to pass in themselves. Passing in all of them and allows the map work out what the bounding box is, e.g. they might have 10 waypoints from a tramp - they can just pass all 10 coordinates in and the map will adjust its bounds to make sure all 10 waypoint coordinates are visible.

Zoom 5 to 12 show the Topo250 map series and zoom 13 to 15 show the Topo50.

The API for specifying a gpx file differs from that for specifying a kml file. See the code for the extra handling required to use the API with a kml file.

Web server

For this recipe to work your web server must be able to serve gpx and kml files. Toy will need to add the media types(approve sites)

  • kml = application/vnd.google-earth.kml+xml
  • gpx = application/gpx+xml[3]

Change log / Release notes

2015-07-01 gpx and kml now work, improve code, production ready 2014-08-09 Make PHP 5.5 compatible

See also

Contributors

Special thanks to Gavin Harriss

Comments

See discussion at NZTopo-Talk?

Page last modified on 2017 Jun 19 07:00

Edit - History - Recent Changes - WikiHelp - Search - ?Subject=KiwiWiki: NZ Topo&Body=From KiwiWiki: NZ Topo (http://kiwiwiki [period] co [period] nz/pmwiki/pmwiki [period] php/Cookbook/NZTopo) - Use [[http://www [period] topomap [period] co [period] nz/ -> mailto:?Subject=KiwiWiki:%20NZ%20Topo&Body=From%20KiwiWiki:%20NZ%20Topo%20(http://kiwiwiki [period] co [period] nz/pmwiki/pmwiki [period] php/Cookbook/NZTopo)%20-%20Use%20[[http://www [period] topomap [period] co [period] nz/ to display an excerpt from a New Zealand map in PmWiki|email page as link]]