Geocaching Map Enhancements can be configured to use many different mapsources, by entering a configuration string. GME builds on Cloudmade's Leaflet Maps API, so the string uses a superset of Leaflet's map layer options, extended for GME-specific functions. These are formatted as a simple JSON string.
OpenStreetMaps Transport: Google-style mapsource, loaded as a basemap:
{"alt":"OSM Transport", "tileUrl":"http://{s}.tile2.opencyclemap.org/transport/{z}/{x}/{y}.png", "maxZoom":18, "attribution":"Maps from <a href=\"http://www.openstreetmap.org/\">OpenStreetMap</a> and contributors <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\">CC-BY-SA</a>" }
Nexrad Weather: WMS mapsource, loaded as an overlay:
{"alt":"Nexrad Weather", "tileUrl":"http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi", "layers":"nexrad-n0r-900913", "format":"image/png", "transparent": true, "attribution":"Weather data © 2012 IEM Nexrad", "overlay":true }
More than one mapsource can be entered at a time by joining them together as a JSON array, e.g. [{mapsource}, {mapsource}, {mapsource}]
, where each "{mapsource}
" is a configuration string like the examples above.
More custom mapsource examples.
Options for GME are based on options for Leaflet Maps TileLayers. The options that are important for GME are listed below. See the Leaflet Maps API documentation for other options, including performance tweaks. However, bear in mind that Geocaching.com may not be using the latest version of Leaflet - check the Leaflet Changelog to see what is supported.
Option | Type | Default value | Description |
---|---|---|---|
alt |
String |
"" |
(required)(GME-specific) e.g. "Streetmap" — the string used by the layer selection control, describes the layer data. |
attribution |
String |
"" |
e.g. "© CloudMade" — the string used by the attribution control, describes the source of the layer data. Can include HTML formatting for links, icons, etc. |
brightness |
Number |
1.0 |
(GME-specific) Brightness level for mapsource, in the range 0 - 1. This option overrides the brightness level set in the GME configuration dialog. |
format |
String |
"image/jpeg" |
(WMS-only) WMS image format (use "image/png" for layers with transparency). |
layers |
String |
"" |
(required for WMS) Comma-separated list of WMS layers to show. |
maxZoom |
Number |
18 |
Maximum zoom number. |
minZoom |
Number |
0 |
Minimum zoom number. |
overlay |
Boolean |
false |
(GME-specific) Whether the mapsource should be loaded as an overlay, rather than a basemap. Multiple overlays can be loaded over the basemap, and independently switched on and off. To be effective, an overlay mapsource must supply transparent tiles. |
styles |
String |
"" |
(WMS-only) Comma-separated list of WMS styles. |
|
|
|
This parameter is no longer supported. |
subdomains |
String or String[] |
"abc" |
Subdomains of the tile service. Some map services use multiple subdomains for their tile URLs. This can make maps load quicker, by allowing web browsers to make more parallel requests. In the URL template, {s} will randomly be replaced by one of the characters from this string. |
tileUrl |
String |
"" |
(required) The base URL for the mapsource's tileserver or WMS server. See table below for the URL template format. |
tileSize |
Number |
256 |
Tile size (width and height in pixels, assuming tiles are square). |
tms |
Boolean |
false |
Set to true if the map source uses TMS standard tile numbering (inverse Y axis numbering compared to Google-style x/y/z references). This replaces the scheme parameter in previous versions of the Leaflet Maps API. |
transparent |
Boolean |
false |
(WMS-only) If true, the WMS service will return images with transparency. |
version |
String |
"1.1.1" |
(WMS-only) Version of the WMS service to use. |
For WMS servers, tileURL
is interpreted as the base URL for requests to the server. For TMS servers, it is interpreted as a template with replaceable parameters that GME fills in to derive the URL for each tile, e.g.:
"http://{s}.somedomain.com/blabla/{z}/{x}/{y}.png"
The table below gives the currently supported parameter substitutions.
Parameter | Description |
---|---|
{s} |
Replaced by a subdomain name, randomly chosen from the list specified by the subdomains option. |
{s4} |
Replaced by a subdomain name calculated by the following algorithm used by Wikimapia:s = x%4 + (y%4)×4 |
{q} |
Replaced by a Bing-style quadkey tile reference. If {q} is specified, {x} , {y} and {z} are not generally necessessary. |
{x} |
Replaced by the x-coordinate of the tile in the TMS or Google-style numbering schemes. |
{x100} |
Replaced by (x-coordinate ÷ 100) of the tile in the TMS or Google-style numbering schemes. (Used by some servers to separate tiles into folders). |
{y} |
Replaced by the y-coordinate of the tile in the TMS or Google-style numbering schemes. |
{z} |
Replaced by the zoom level of the tile. |