Google Maps Integration for PmWiki
Version 0.7 - Last Updated: 18-Nov-2007
Why another Google Maps plugin for PmWiki? Ben Wilson did a very nice one that I've been using for over a year now, but nothing has really happened on progress towards 2.2.0 in almost a year. I understand that people get busy with other projects (Lord knows I'm guilty as charged), but the license specifically forbids modification or redistribution of his code. I needed to make changes, and it seemed that if I was already going to do that, I might as well just create a new one that could be considered Free Software, so that others can help me work on it and add new features.
In an effort to ease the transition of dozens of pages I already have coded, I kept as much of his wiki directive syntax as possible. It's an entirely new codebase, however.
Features
- Currently only supports the Google Maps API, but my intention is to allow it to at least support Yahoo Maps as well.
- Supports basic map display, lines, and points
- Supports encoded polylines, for more efficient display of complex lines with large numbers of points.
- Supports multiple maps on one page (at least theoretically). I haven't tested it extensively, but I think it works.
- Wiki-directive compatible with Ben Wilson's GoogleMapsAPI recipe, except for the name of the tags themselves (ie, all the options are the same, though you'll need to change gma-map to map-display, gma-line to map-line and gma-point to map-point).
- MapsAPI.php is Free Software under the MIT License
| Version | Download | Release Notes |
| 0.7 | TGZ | Initial public release |
- Unzip the contents of the file (MapsAPI.php and PolyEncode.php) into PmWiki's
cookbook/ directory.
- Add the following to your
local/config.php file:
include_once('cookbook/MapsAPI.php');
- @@$GoogleMapsKey='(your site's Google Maps key)';
- Modify the defaults at the top of
MapsAPI.php to fit your preferences
- That's it - it should work now!
Maps
The (:map-display:) directive allows a user to place an embedded Google Map in any given PmWiki page. It doesn't really matter where the rest of the directives are in the wiki text - the (:map-display:) is what actually causes the map to get displayed.
Example:
(:map-display width='99%' height='500px' ctrl='small,-overview' lat=37 lon=-107 zoom=8 :)
| (:map-display [options] :) |
| Option | Values/Use |
| zoom | Initial zoom level of the map, 1-18. 1 is the furthest out, 18 the closest in. |
| lat | Latitude of point to initially center map on - decimal degrees, WGM84 datum |
| lon | Longitude of point to initially center map on - decimal degrees, WGM84 datum |
| width | Width of map to be displayed, in any CSS units (px, %, etc.) |
| height | Height of map to be displayed, in any CSS units (px, %, etc.) |
| map_id | (Optional) Name of map, used to identify which map to display points and lines on if a page has multiple maps |
| view | (Optional) Initial map view - normal, hybrid, or satellite |
| ctrl | (Optional) Map control options - prepend a '-' to turn off: small/large - Map navigation control size overview - Show overview map in lower left maptype - Allow user to change normal/hybrid/satellite encodepoly - Use encoded polylines |
Points
The (:map-point:) directive allows a user to display a point on the map, with an optional capability to display text in a pop-up window when the point is clicked (see the text option).
Example:
(:map-point lat=37.013345 lon=-106.336419 zoom=10
text='<img src="http://www.drgw.net/info/uploads/Main/osier-thumb.jpg"
align="left" style="margin:4px;width:120px;height:80px" >' :)
Note: If embedding images into the pop-up box, be sure to specify a size (width:120px;height:80px) in the style attribute on the img tag. Otherwise, the popup box may not be of the correct size the first time around, since the image size isn't known until it's loaded.
| (:map-point [options] :) |
| Option | Values/Use |
| lat | Latitude of point - decimal degrees, WGM84 datum |
| lon | Longitude of point - decimal degrees, WGM84 datum |
| zoom | (Optional) Minimum zoom level at which to show point - 1-18, set to 1 for always show (default) |
| map_id | (Optional) Name of map, used to identify which map to display points and lines on if a page has multiple maps |
| text | (Optional) HTML text to put in pop-up box when point is clicked |
| icon | (Optional) URL to use for point marker icon |
Lines
The (:map-line:) directive allows a user to draw lines on a map, specifying one point per command. If encoded polylines are enabled, lines will be dynamically encoded at page request time. Encoded polylines are preferred for large, complex polylines, since they are more concisely expressed and eliminate detail that is unnecessary at varying zoom levels. Less detail translates to faster map display and interaction, so the user experience should be better.
Note: Opacity, color, and thickness should only be specified once per line id. If you specify them multiple times, the last one will be used.
Example:
(:map-line id=3746 lon=-106.462095 lat=37.021479 color='#ff0000' opacity=90 thickness=2 :)
(:map-line id=3746 lon=-106.460097 lat=37.021780:)
(:map-line id=3746 lon=-106.459269 lat=37.021713:)
(:map-line id=3746 lon=-106.459240 lat=37.021700:)
(:map-line id=3746 lon=-106.458783 lat=37.021485:)
(:map-line id=3746 lon=-106.458553 lat=37.020958:)
(:map-line id=3746 lon=-106.458466 lat=37.020501:)
| (:map-line [options] :) |
| Option | Values/Use |
| lat | Latitude of point - decimal degrees, WGM84 datum |
| lon | Longitude of point - decimal degrees, WGM84 datum |
| id | Line id, used to associate individual points into a common line |
| map_id | (Optional) Name of map, used to identify which map to display points and lines on if a page has multiple maps |
| opacity | (Optional) Opacity of line overlayed on map |
| thickenss | (Optional) Thickness of line, in pixels |
| color | (Optional) Line color, specified in standard html form #RRGGBB |