[Pkg-javascript-commits] [modestmaps-js] 03/04: Imported Upstream version 3.3.6+ds1

Andrew Harvey andrewharvey-guest at alioth.debian.org
Sun Sep 29 10:51:54 UTC 2013


This is an automated email from the git hooks/post-receive script.

andrewharvey-guest pushed a commit to branch master
in repository modestmaps-js.

commit 0741a3343ca45fabfaf4b8bd81a2113a1ad8ce95
Author: Andrew Harvey <andrew.harvey4 at gmail.com>
Date:   Sun Sep 29 20:47:15 2013 +1000

    Imported Upstream version 3.3.6+ds1
---
 .gitignore                               |    2 +
 CHANGELOG                                |   10 +
 Makefile                                 |   18 +-
 VERSION                                  |    1 +
 doc/.gitignore                           |    2 +
 doc/Makefile                             |   15 +
 doc/api.md                               | 1168 ++++++++++++++++++++++++++
 doc/css/main.css                         |  206 +++++
 doc/end.html                             |    3 +
 doc/index.html                           | 1350 ++++++++++++++++++++++++++++++
 doc/middle.html                          |    3 +
 doc/start.html                           |   12 +
 doc/toc.md                               |  108 +++
 examples/geojson/modestmaps.markers.js   |    2 +-
 examples/node/modestmaps-static.js       |   41 +-
 examples/spotlight/modestmaps.markers.js |    2 +-
 modestmaps.js                            |   13 +-
 modestmaps.min.js                        |    8 +-
 package.json                             |    2 +-
 src/layer.js                             |    2 +
 src/map.js                               |    5 +-
 src/provider.js                          |    4 +-
 src/start.js                             |    2 +-
 test/spec/Map.js                         |    7 +
 24 files changed, 2933 insertions(+), 53 deletions(-)

diff --git a/.gitignore b/.gitignore
index 3c3629e..c2977b1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,3 @@
 node_modules
+.swp
+.*.swp
diff --git a/CHANGELOG b/CHANGELOG
index edcf945..4db5bcb 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -8,6 +8,16 @@ Following the semantic versioning recommendation best we can:
     minor version, and backwards incompatible API changes increment
     the major version." -- http://semver.org/
 
+v3.3.6
+- .enable() and .disable() return the layer object as expected
+- `setCenter()` now correctly calls enforceLimits so that `locationPoint`
+  is immediately accurate.
+- Examples fixes
+- Now builds with uglifyjs instead of YUICompressor
+
+v3.3.5
+- Fixes rounding bug in MapProvider's `sourceCoordinate`
+
 v3.3.4
 - Layers no longer copy their CSS properties from their parent nodes,
   so that parent node CSS can be changed with properties like `clip` and
diff --git a/Makefile b/Makefile
index 6c90eb4..e49a4cd 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,6 @@
+NODE_PATH ?= ./node_modules
+JS_COMPILER = $(NODE_PATH)/uglify-js/bin/uglifyjs
+
 JS_FILES = \
 	src/start.js \
 	src/utils.js \
@@ -17,16 +20,21 @@ JS_FILES = \
 	src/convenience.js \
 	src/end.js
 
-all: modestmaps.js modestmaps.min.js
+VERSION = `cat VERSION`
+
+all: update-version modestmaps.js modestmaps.min.js
 
 modestmaps.min.js: modestmaps.js
 	rm -f modestmaps.min.js
-	java -jar tools/yuicompressor-2.4.2.jar modestmaps.js > modestmaps.min.js
+	$(JS_COMPILER) modestmaps.js > modestmaps.min.js
 
 modestmaps.js: $(JS_FILES) Makefile
 	rm -f modestmaps.js
-	cat $(JS_FILES) >> modestmaps.js
+	cat $(JS_FILES) | perl -pi -e "s/{VERSION}/$(VERSION)/g" > modestmaps.js
+
+update-version:
+	perl -pi -e "s/\"version\": \"[^\"]+/\"version\": \"$(VERSION)/g" package.json
 
 clean:
-	rm modestmaps.js
-	rm modestmaps.min.js
+	rm -f modestmaps.js
+	rm -f modestmaps.min.js
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..9c25013
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+3.3.6
diff --git a/doc/.gitignore b/doc/.gitignore
new file mode 100644
index 0000000..9734b2f
--- /dev/null
+++ b/doc/.gitignore
@@ -0,0 +1,2 @@
+api.html
+toc.html
diff --git a/doc/Makefile b/doc/Makefile
new file mode 100644
index 0000000..12fbb04
--- /dev/null
+++ b/doc/Makefile
@@ -0,0 +1,15 @@
+# to install marked: `npm install marked`
+MARKED ?= ../node_modules/marked/bin/marked --gfm
+VERSION = `cat ../VERSION`
+
+all: index.html
+
+index.html: toc.html api.html
+	cat start.html toc.html middle.html api.html end.html \
+		| perl -pi -e "s/{VERSION}/$(VERSION)/g" > $@
+
+%.html: %.md
+	$(MARKED) $< > $@
+
+clean:
+	rm -f index.html toc.html api.html
diff --git a/doc/api.md b/doc/api.md
new file mode 100644
index 0000000..7a995cc
--- /dev/null
+++ b/doc/api.md
@@ -0,0 +1,1168 @@
+# modestmaps.js
+Modest Maps is a bare-bones geographic map display and interaction library. It was designed and conceived by [Tom Carden], tweaked by [Michal Migurski], and is maintained and hacked on primarily by [Tom MacWright] and [Shawn Allen].
+
+[Tom Carden]: http://www.tom-carden.co.uk/
+[Michal Migurski]: http://mike.teczno.com/
+[Tom MacWright]: http://macwright.org/
+[Shawn Allen]: http://github.com/shawnbot
+
+<a name="source"></a>
+## Getting the Source
+You can get modestmaps.js by cloning [the github repo](https://github.com/modestmaps/modestmaps-js/) or downloading it:
+
+* [modestmaps.js-v{VERSION}.zip](https://github.com/modestmaps/modestmaps-js/zipball/v{VERSION}) (zip archive)
+* [modestmaps.js](../modestmaps.js) (source JavaScript, 100K)
+* [modestmaps.min.js](../modestmaps.min.js) (minified JavaScript, 36K)
+
+After you've downloaded it, you can include by putting this `<script>` tag into the `<head>` of your HTML document:
+
+```
+<script type="text/javascript" src="modestmaps.js"></script>
+```
+
+<a name="quick-start"></a>
+## Quick Start
+
+<a name="quick.map"></a>
+### Making a Map
+Making a map is easy. First, you'll need a place for your map in the HTML:
+
+```
+<div id="map"></div>
+```
+
+Then, add a script below:
+
+```
+<script type="text/javascript">
+var tiles = new MM.TemplatedLayer("http://tile.stamen.com/toner/{Z}/{X}/{Y}.png");
+var size = new MM.Point(640, 480);
+var map = new MM.Map("map", tiles, size);
+</script>
+```
+
+This will create a map showing [Stamen's toner tiles](http://maps.stamen.com/toner/) in a 640x480-pixel area. See the docs below for more info on [layers](#TemplatedLayer) and [map dimensions](#Map.dimensions).
+
+If you want the size of your map to be determined by CSS, you can style your div like so:
+
+```
+#map {
+    height: 500px;
+}
+```
+
+Then, leave off the `size` argument to the constructor:
+
+```
+<script type="text/javascript">
+var tiles = new MM.TemplatedLayer("http://tile.stamen.com/toner/{Z}/{X}/{Y}.png");
+var map = new MM.Map("map", tiles);
+</script>
+```
+
+For more info on resizing, see the [Map constructor](#Map.constructor) and [autoSize](#Map.autoSize) docs.
+
+<a name="quick.moving"></a>
+### Moving Around
+Once you've got your map initialized, you can move it around the world. Geographic locations in modestmaps.js are modeled with the [Location](#Location) class, which is called with *latitude* and *longitude* values:
+
+```
+var oakland = new MM.Location(37.804, -122.271);
+```
+
+Once you've got a location, you can tell the map to center on it by calling [setCenter](#Map.setCenter):
+
+```
+// center on Oakland, California
+map.setCenter(oakland);
+// center on Amsterdam, Netherlands
+map.setCenter(new MM.Location(52.3702157, 4.8951679));
+```
+
+You can get the current center of the map with [getCenter](#Map.getCenter). You can also modify the visible area by setting its [extent](#Extent), which is defined by two or more locations. [Setting](#Map.setCenter) a map's extent adjusts its center and zoom level so that the rectangular bounding box surrounding the locations is entirely visible:
+
+```
+var oakland = new MM.Location(37.804, -122.271),
+    amsterdam = new MM.Location(52.3702157, 4.8951679);
+var extent = new MM.Extent(oakland, amsterdam);
+map.setExtent(extent)
+```
+
+You can change the map's zoom level with the [zoomIn](#Map.zoomIn), [zoomOut](#Map.zoomOut) and [zoomTo](#Map.zoomTo) methods:
+
+```
+map.zoomIn();   // increase zoom by 1
+map.zoomOut();  // decrease zoom by 1
+map.zoomTo(12); // zoom to level 12
+```
+
+<a name="quick.layers"></a>
+### Working with Layers
+One popular feature of many online maps is a "hybrid" style, which overlays satellite imagery with graphical labels. You can achieve this effect in modestmaps.js by creating two [tile layers](#TemplatedLayer), and passing them both to the [Map constructor](#Map.constructor) as an array:
+
+```
+var baseURL = "http://tile.stamen.com/",
+    watercolor = new MM.TemplatedLayer(baseURL + "watercolor/{Z}/{X}/{Y}.jpg"),
+    labels = new MM.TemplatedLayer(baseURL + "toner-labels/{Z}/{X}/{Y}.jpg");
+var map = new MM.Map("map", [watercolor, labels]);
+```
+
+Or you can create the map with one layer, then add the overlay later:
+
+```
+var map = new MM.Map("map", watercolor);
+map.addLayer(labels);
+```
+
+See the [addLayer](#Map.addLayer) docs and the [TemplatedLayer](#TemplatedLayer) class reference for more on working with layers.
+
+<a name="Map"></a>
+## MM.Map
+The Map class is the core of **modestmaps.js**.
+
+```
+new MM.Map(parent [, layerOrLayers [, dimensions [, eventHandlers]]])
+```
+
+Creates a new map inside the given **parent** element, containing the specified **layers**, optionally with the specified **dimensions** in pixels and custom **event handlers**. The **Map** constructor arguments are described in detail below:
+
+#### parent
+The parent [element](http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-745549614) of the map. This is typically a `String` indicating the ID of the element:
+
+```
+var map = new MM.Map("map", []);
+```
+
+You can also provide an element reference:
+
+```
+var firstDiv = new MM.Map(document.querySelector("div.map"), ...);
+```
+
+Here's a pattern for inserting maps into a series of classed elements, using [document.getElementsByClassName](https://developer.mozilla.org/en/DOM/document.getElementsByClassName):
+
+```
+var elements = document.getElementsByClassName("map"),
+    maps = [];
+for (var i = 0; i < elements.length; i++) {
+  maps[i] = new MM.Map(elements[i], ...);
+}
+```
+
+If an element with the provided ID string is not found, an exception is raised.
+
+If **parent** is not an object or a string, an exception is raised.
+
+
+#### layerOrLayers
+Either a single [layer](#Layer) object or an array of layer objects. Layer objects should either be instances of the [Layer](#Layer) class or implement the [Layer interface](#Layer-Interface).
+
+Here's an example of a map with two tile layers, from maps.stamen.com:
+
+```
+var baseURL = "http://tile.stamen.com/",
+    watercolor = new MM.TemplatedLayer(baseURL + "watercolor/{Z}/{X}/{Y}.png"),
+    labels = new MM.TemplatedLayer(baseURL + "toner-labels/{Z}/{X}/{Y}.png");
+var map = new MM.Map("map", [watercolor, labels]);
+```
+
+NOTE: Before modestmaps.js *v3.1.1*, an exception was raised if **layerOrLayers** was not an object or an array.
+
+
+#### dimensions
+An optional map size in pixels, expressed as a [Point](#Point) object.
+
+```
+var size = new MM.Point(512, 512);
+var map = new MM.Map("map", [], size);
+console.log("map size:", map.dimensions.x, "x", map.dimensions.y);
+```
+
+If **dimensions** is `null` or `undefined`, the dimensions are derived from
+the width and height of the parent element, and the map's [autoSize](#Map.autoSize)
+flag is set to `true`.
+
+Empty `<div>` elements have no intrinsic height, so if you don't provide dimensions you'll need to provide the map's parent height in CSS (either inline or in a stylesheet).
+
+#### eventHandlers
+An optional array of interaction event handlers, which should implement the [EventHandler interface](#EventHandler-Interface). If no handlers are provided (`eventHandlers === undefined`), the map is initialized with [mouse](#MouseHandler) and [touch](#TouchHandler) handlers.
+
+For instance, to create a map without scroll wheel zooming (which is enabled by default), you can provide [drag](#DragHandler), and [double-click](#DoubleClickHandler) handlers:
+
+```
+var map = new MM.Map("map", [], null, [
+  new MM.DragHandler(),
+  new MM.DoubleClickHandler()
+]);
+```
+
+The [touch](#TouchHandler) handler provides panning and zooming in touch-enabled browsers:
+
+```
+var map = new MM.Map("map", [], null, [
+  new MM.TouchHandler()
+]);
+```
+
+To initialize the map without any interaction handlers, specify **eventHandlers** as `null` or an empty array (`[]`).
+
+
+<a name="Map.getCenter"></a>
+### getCenter `map.getCenter()`
+Get the map's center **location**.
+
+```
+var center = map.getCenter();
+console.log("center latitude:", center.lat, "+ longitude:", center.lon);
+```
+
+<a name="Map.setCenter"></a>
+### setCenter `map.setCenter(location)`
+Set the map's center **location**.
+
+```
+var center = new MM.Location(37.764, -122.419);
+map.setCenter(center);
+```
+
+<a name="Map.getZoom"></a>
+### getZoom `map.getZoom()`<a name="Map.getZoom"></a>
+Get the map's **zoom level**.
+
+```
+var zoom = map.getZoom();
+console.log("zoom level:", zoom);
+```
+
+<a name="Map.setZoom"></a>
+### setZoom `map.setZoom(zoom)`
+Set the map's **zoom level**.
+
+```
+map.setZoom(17);
+```
+
+<a name="Map.setCenterZoom"></a>
+### setCenterZoom `map.setCenterZoom(location, zoom)`
+Set the map's center **location** and **zoom level**.
+
+```
+map.setCenterZoom(new MM.Location(37.764, -122.419), 17);
+```
+
+<a name="Map.getExtent"></a>
+### getExtent `map.getExtent()`
+Get the visible extent (bounds) of the map as an [Extent](#Extent) object.
+
+```
+var extent = map.getExtent();
+console.log("northwest location:", extent.northWest());
+console.log("southeast location:", extent.southEast());
+```
+
+<a name="Map.setExtent"></a>
+### setExtent `map.setExtent(extent [, precise])`
+Modify the center and zoom of the map so that the provided **extent** is visible. If **precise** is `true`, resulting zoom levels may be fractional. (By default, the map's zoom level is rounded down to keep tile images from blurring.)
+
+```
+var extent = new MM.Extent(
+  new MM.Location(55.679, 12.584),
+  new MM.Location(55.668, 12.607)
+);
+map.setExtent(extent, true);
+```
+
+NOTE: For historical reasons, **setExtent** also accepts an array of [Location](#Location) objects, which are converted using [Extent.fromArray](#Extent.fromArray).
+
+<a name="Map.zoomIn"></a>
+### zoomIn `map.zoomIn()`
+Increase the map's zoom level by one.
+
+<a name="Map.zoomOut"></a>
+### zoomOut `map.zoomOut()`
+Decrease the map's zoom level by one.
+
+<a name="Map.zoomBy"></a>
+### zoomBy `map.zoomBy(zoomOffset)`
+Zoom the map by the provided **offset**. Positive offsets zoom in; negative offsets zoom out.
+
+```
+// this is the equivalent of calling map.zoomIn() twice:
+map.zoomBy(2);
+```
+
+<a name="Map.zoomByAbout"></a>
+### zoomByAbout `map.zoomByAbout(zoomOffset, point)`
+Zoom the map by the provided **zoom offset** from a **point** on the screen in pixels. Positive offsets zoom in; negative offsets zoom out. This function is used by [DoubleClickHandler](#DoubleClickHandler) to zoom in on the point where the map is double-clicked.
+
+```
+// zoom in on the upper left corner
+var point = new MM.Point(0, 0);
+map.zoomByAbout(1, point);
+```
+
+<a name="Map.panBy"></a>
+### panBy `map.panBy(x, y)`
+Pan the map by the specified **x** and **y** distance in pixels. Positive values move the map right and down, respectively; negative values move the map left and up.
+
+```
+// pan 500 pixels to the right
+map.panBy(500, 0);
+// pan 200 pixels up
+map.panBy(0, -200);
+```
+
+<a name="Map.panLeft"></a>
+### panLeft `map.panLeft()`
+<a name="Map.panRight"></a>
+### panRight `map.panRight()`
+<a name="Map.panUp"></a>
+### panUp `map.panUp()`
+<a name="Map.panDown"></a>
+### panDown `map.panDown()`
+Pan the map to the left, right, up or down by 100 pixels. To vary the offset distance, use [panBy](#Map.panBy).
+
+<a name="Map.getLayers"></a>
+### getLayers `map.getLayers()`
+Get a copy of the map's layers array.
+
+```
+var layers = map.getLayers();
+var base = layers[0];
+```
+
+<a name="Map.getLayerAt"></a>
+### getLayerAt `map.getLayerAt(index)`
+Get the layer at a specific **index**. The first layer is at index `0`, the second at `1`, etc.
+
+```
+var map = new MM.Map(...);
+var base = map.getLayerAt(0);
+base.parent.id = "base";
+```
+
+<a name="Map.addLayer"></a>
+### addLayer `map.addLayer(layer)`
+Add **layer** to the map's [layer stack](#Map.layers)]. This triggers a [redraw](#Map.redraw).
+
+```
+var layer = new MM.TemplatedLayer("http://tile.stamen.com/toner-lines/{Z}/{X}/{Y}.png");
+map.addLayer(layer);
+```
+
+<a name="Map.removeLayer"></a>
+### removeLayer `map.removeLayer(layer)`
+Remove **layer** from the map's [layer stack](#Map.layers).
+
+<a name="Map.setLayerAt"></a>
+### setLayerAt `map.setLayerAt(index, newLayer)`
+Replace the existing layer at **index** with the **new layer**.
+
+```
+var layer = new MM.TemplatedLayer("http://tile.stamen.com/toner/{Z}/{X}/{Y}.png");
+map.setLayerAt(0, layer);
+```
+
+<a name="Map.insertLayerAt"></a>
+### insertLayerAt `map.insertLayerAt(index, layer)`
+Insert a **layer** at the provided **index**.
+
+```
+// let's assume the map has 2 layers already
+var layer = new MM.TemplatedLayer("http://tile.stamen.com/toner-lines/{Z}/{X}/{Y}.png");
+map.insertLayerAt(1, layer);
+// (now it has 3, with our new layer at index 1)
+```
+
+<a name="Map.removeLayerAt"></a>
+### removeLayerAt `map.removeLayerAt(index)`
+Remove the layer at the provided index.
+
+```
+// remove the second layer
+map.removeLayerAt(1);
+```
+
+<a name="Map.swapLayersAt"></a>
+### swapLayersAt `map.swapLayersAt(indexA, indexB)`
+Swap the z-index (order) or the layers at **indexA** and **indexB**.
+
+```
+// swap the bottom and top layers
+var bottom = 0,
+    top = map.getLayers().length - 1;
+map.swapLayersAt(bottom, top);
+```
+
+<a name="Map.pointLocation"></a>
+### pointLocation `map.pointLocation(screenPoint)`
+Convert a **point on the screen** to a [location](#Location) (a point on the Earth).
+
+<a name="Map.pointCoordinate"></a>
+### pointCoordinate `map.pointCoordinate(screenPoint)`
+Convert a **point on the screen** to a [tile coordinate](#Coordinate).
+
+<a name="Map.locationPoint"></a>
+### locationPoint `locationPoint(location)`
+Convert a **location** (a point on the Earth) to a [point](#Point) on the screen.
+
+<a name="Map.locationCoordinate"></a>
+### locationCoordinate `map.locationCoordinate(location)`
+Convert a **location** (a point on the Earth) to a [tile coordinate](#Coordinate).
+
+<a name="Map.coordinateLocation"></a>
+### coordinateLocation `map.coordinateLocation(coord)`
+Convert a [tile coordinate](#Coordinate) to a [location](#Location) (a point on the Earth).
+
+<a name="Map.coordinatePoint"></a>
+### coordinatePoint `map.coordinatePoint(coord)`
+Convert a [tile coordinate](#Coordinate) to a [point](#Point) on the screen.
+
+<a name="Map.setZoomRange"></a>
+### setZoomRange `map.setZoomRange(minZoom, maxZoom)`
+Set the map's **minimum** and **maximum** zoom levels. This function modifies the zoom levels of the map's [coordLimits](#Map.coordLimits).
+
+<a name="Map.setSize"></a>
+### setSize `map.setSize(dimensions)`
+Set the map's **dimensions** in pixels. If the map's [autoSize](#Map.autoSize) flag is `true`, setting the size manually sets **autoSize** to `false` and prevents further automatic resizing.
+
+```
+map.setSize(new MM.Point(640, 480));
+```
+
+NOTE: The map's current size is available in its [dimensions](#Map.dimensions) property.
+
+<a name="Map.addCallback"></a>
+### addCallback `map.addCallback(eventType, callback)`
+Add a **callback function** (listener) to the map for a specific **event type**. Callback functions always receive the map instance as their first argument; additional arguments differ by event type. See the [events list](#Map-events) for supported types.
+
+```
+function onPanned(map, offset) {
+  console.log("panned by", offset[0], offset[1]);
+}
+
+map.addCallback("panned", onPanned);
+```
+
+You can remove callbacks with [removeCallback](#Map.removeCallback).
+
+<a name="Map.removeCallback"></a>
+### removeCallback `map.removeCallback(eventType, callback)`
+Remove a **callback function** (listener) for the given **event type**. You can add callbacks with [addCallback](#Map.addCallback).
+
+```
+map.removeCallback("panned", onPanned);
+```
+
+<a name="Map.draw"></a>
+### draw `map.draw()`
+Redraw the map and its layers. First, the map enforces its [coordLimits](#Map.coordLimits) on its center and zoom. If [autoSize](#Map.autoSize) is `true`, the map's dimensions are recalculated from its [parent](#Map.parent). Lastly, each of the map's layers is [drawn](#Layer.draw).
+
+<a name="Map.requestRedraw"></a>
+### requestRedraw `map.requestRedraw()`
+Request a "lazy" call to [draw](#Map.draw) in 1 second. This is useful if you're responding to lots of user input and know that you'll need to redraw the map *eventually*, but not immediately.
+
+Multiple calls to **requestRedraw** within 1 second of one another will be ignored, so this is a perfectly reasonable thing to do:
+
+```
+setInterval(function() {
+  map.requestRedraw();
+}, 100);
+```
+
+
+## Hybrid Methods
+Hybrid methods behave differently depending on whether they receive arguments: The "getter" form (with no arguments) returns the current value, and the "setter" form sets it to the value provided then returns `this`, which makes function chaining possible (a la [jQuery](http://jquery.com), [d3](http://d3js.com), and [Polymaps](http://polymaps.org)).
+
+<a name="Map.center"></a>
+### center `map.center([location])`
+[Get](#Map.getCenter) or [set](#Map.setCenter) the map's center **location**.
+
+```
+var center = map.center();
+center.lat += .1;
+map.center(center);
+```
+
+<a name="Map.zoom"></a>
+### zoom `map.zoom([level])`
+[Get](#Map.getZoom) or [set](#Map.setZoom) the map's **zoom level**.
+
+```
+var zoom = map.zoom();
+zoom -= 3;
+map.zoom(zoom);
+```
+
+<a name="Map.extent"></a>
+### extent `map.extent([locationsOrExtent [, precise]])`
+[Get](#Map.getZoom) or [set](#Map.setZoom) the map's extent. If **precise** is `true`, resulting zoom levels may be fractional.
+
+```
+// get the extent, check if it contains a location…
+var extent = map.extent(),
+    loc = new MM.Location(37.764, -122.419);
+if (!extent.containsLocation(loc)) {
+  // then enclose the location and set the map's new extent
+  extent.encloseLocation(loc);
+  map.extent(extent);
+}
+```
+
+## Map Properties
+
+<a name="Map.autoSize"></a>
+### autoSize `map.autoSize`
+The **autoSize** property is set to `true` if no dimensions are provided in the [constructor](#Map). When **autoSize** is `true`, the map's dimensions are recalculated (and the map is [redrawn](#Map.draw)) [on window resize](https://developer.mozilla.org/en/DOM/window.onresize).
+
+<a name="Map.coordinate"></a>
+### coordinate `map.coordinate`
+The map's current center [coordinate](#Coordinate).
+
+<a name="Map.coordLimits"></a>
+### coordLimits `map.coordLimits`
+An array specifying the map's coordinate bounds, in which the first element defines the top left (northwest) and outermost zoom level, and the second defines the bottom right (southwest) and innermost zoom.
+
+You can adjust the minimum and maximum zoom levels of the map without affecting the bounds with [setZoomRange](#Map.setZoomRange).
+
+<a name="Map.dimensions"></a>
+### dimensions `map.dimensions`
+The map's current dimensions, expressed as a [Point](#Point).
+
+```
+// the bottom right screen coordinate is also its southeast point
+var southEast = map.pointLocation(map.dimensions);
+```
+
+<a name="Map.parent"></a>
+### parent `map.parent`
+The map's parent (container) DOM element.
+
+```
+map.parent.style.backgroundColor = "green";
+```
+
+<a name="Map.projection"></a>
+### projection `map.projection`
+The map's projection, also known as Coordinate Reference System (CRS) or Spatial Reference System (SRS).
+
+<a name="Map.tileSize"></a>
+### tileSize `map.tileSize`
+The pixel dimensions of the map's individual image tiles, expressed as a [Point](#Point). By default, tiles are **256** pixels square.
+
+```
+// you can use the tile size to estimate the number of tiles visible
+// at any given moment:
+var maxRows = Math.ceil(map.dimensions.x / map.tileSize.x);
+var maxCols = Math.ceil(map.dimensions.y / map.tileSize.y);
+var maxTiles = maxRows * maxCols;
+console.log("max tiles:", maxTiles);
+```
+
+<a name="Map-events"></a>
+## Map Events
+Map events are triggered when the map moves (either in response to a direct function call or indirectly, through user interaction with an event handlers) or is [drawn](#Map.draw). You can start and stop listening for map events with [addCallback](#Map.addCallback) and [removeCallback](#Map.removeCallback):
+
+```
+function onDrawn(map) {
+  console.log("map drawn!");
+}
+
+// After this, the onDrawn will be called whenever the map changes.
+map.addCallback("drawn", onZoomed);
+// Later, remove the callback.
+map.removeCallback("drawn", onZoomed);
+```
+
+<a name="Map-zoomed"></a>
+### "zoomed" `function(map, zoomOffset) { ... }`
+Fires when the **map's** zoom level changes, usually in response to [zoomBy](#Map.zoomBy) or [zoomByAbout](#Map.zoomByAbout). Note that the **zoom offset** is the *difference* between the last zoom level and the new zoom level. You can query the map's current zoom level (rather than the offset) with [getZoom](#Map.getZoom).
+
+```
+map.addCallback("zoomed", function(map, zoomOffset) {
+  console.log("map zoomed by:", zoomOffset);
+});
+```
+
+<a name="Map-panned"></a>
+### "panned" `function(map, panOffset) { ... }`
+Fires when the **map** is panned, and receives the **pan offset** (delta) in pixels as a two-element array (`[dx, dy]`).
+
+```
+map.addCallback("panned", function(map, panOffset) {
+  var dx = panOffset[0],
+      dy = panOffset[1];
+  console.log("map panned by x:", dx, "y:", dy);
+});
+```
+
+<a name="Map-resized"></a>
+### "resized" `function(map, dimensions) { ... }`
+Fires when the **map** is resized, and receives the map's new **dimensions** as a [Point](#Point) object.
+
+```
+map.addCallback("panned", function(map, dimensions) {
+  console.log("map dimensions:", dimensions.x, "y:", dimensions.y);
+});
+```
+
+<a name="Map-extentset"></a>
+### "extentset" `function(map, locationsOrExtent) { ... }`
+Fires whenever the **map's** full extent is set, and receives the [Extent](#Extent) or array of [Location](#Location) objects provided to [setExtent](#Map.setExtent) or [extent](#Map.extent).
+
+```
+map.addCallback("extentset", function(map, extent) {
+  // convert to an Extent instance if it's a Location array
+  if (extent instanceof Array) {
+    extent = MM.Extent.fromArray(extent);
+  }
+  console.log("map extent:", extent);
+});
+```
+
+<a name="Map-drawn"></a>
+### "drawn" `function(map) { ... }`
+Fires whenever the **map** is [redrawn](#Map.draw).
+
+```
+map.addCallback("drawn", function(map) {
+  console.log("map drawn!");
+});
+```
+
+<a name="Location"></a>
+## MM.Location
+Location objects represent [geographic coordinates](http://en.wikipedia.org/wiki/Geographic_coordinate_system) on the Earth's surface, expressed as degrees *latitude* and *longitude*. The constructor takes these two values as its arguments:
+
+```
+new MM.Location(latitude, longitude)
+```
+
+Locations are most often used when [getting](#Map.getCenter) and [setting](#Map.setCenter) the center of a [map](#Map). You can read the latitude and longitude of a Location by accessing its `lat` and `lon` properties, respectively:
+
+```
+var center = map.getCenter(),
+    latitude = center.lat,
+    longitude = center.lon;
+```
+
+Note that the [Map](#Map) class doesn't store any references to Location objects internally. Both the [getCenter](#Map.getCenter) and [setCenter](#Map.setCenter) methods convert between geographic and [tile coordinate](#Coordinate) systems, and return copies of objects rather than references. This means that changing the `lat` and `lon` properties of a Location object returned from **getCenter** won't change the map's center; you have to call **setCenter** with the modified Location object.
+
+<a name="Location.lat"></a>
+### lat `location.lat`
+The location's **latitude**, or distance from the Earth's [equator](http://en.wikipedia.org/wiki/Prime_meridian) in degrees. `-90` is at the bottom of the globe (the south pole in Antarctica), `0` is at the equator, and `90` is at the top (the north pole in the Arctic Ocean).
+
+**NOTE:** Because ModestMaps uses a [spherical Mercator projection](http://en.wikipedia.org/wiki/Mercator_projection), points at Earth's extreme north and south poles become infinitely large and impossible to model. This limits the effective range of web maps to `±85º`, depending on zoom level. Setting a map's center to a Location with a latitude outside of this range will most likely have undesired consequences.
+
+<a name="Location.lon"></a>
+### lon `location.lon`
+The location's **longitude**, or distance from the [prime meridian](http://en.wikipedia.org/wiki/Prime_meridian) in degrees. Positive values are east of the prime meridian (towards Asia); negative values are west (towards North America). `±180` degrees is near the [international date line](http://en.wikipedia.org/wiki/International_Date_Line). Longitude values outside of the `[-180, 180]` range "wrap", so a longitude of `190` degrees may be converted to `-170` in certain calculations.
+
+<a name="Location.fromString"></a>
+### Location.fromString `MM.Location.fromString(str)`
+Parse a string in the format `"lat,lon"` into a new Location object.
+
+<a name="Location.distance"></a>
+### Location.distance `MM.Location.distance(a, b, earthRadius)`
+Get the physical distance (along a [great circle](http://en.wikipedia.org/wiki/Great_circle)) between locations **a** and **b**, assuming an optional **Earth radius**:
+
+* `6378000` meters (the default)
+* `3963.1` "statute" miles
+* `3443.9` nautical miles
+* `6378` kilometers
+
+<a name="Location.interpolate"></a>
+### Location.interpolate `MM.Location.interpolate(a, b, t)`
+Interpolate along a [great circle](http://en.wikipedia.org/wiki/Great_circle) between locations **a** and **b** at bias point **t** (a number between 0 and 1).
+
+<a name="Location.bearing"></a>
+### Location.bearing `MM.Location.bearing(a, b)`
+Determine the direction in degrees between locations **a** and **b**. Note that bearing direction is not constant along significant [great cirlce](http://en.wikipedia.org/wiki/Great_circle) arcs.
+
+<a name="Location-location"></a>
+### A warning about the `location` variable name
+Because browsers reserve the `window.location` variable for [information](https://developer.mozilla.org/en/DOM/window.location) about the current page location, we suggest using variable names other than `location` to avoid namespace conflicts. `center` and `loc` are good alternatives.
+
+
+<a name="Extent"></a>
+## MM.Extent
+Extent objects represent rectangular geographic bounding boxes, and are identified by their `north`, `south`, `east` and `west` bounds. North and south bounds are expressed as degrees [latitude](#Location.lat); east and west bounds are degrees [longitude](#Location.lon). The constructor takes two forms:
+
+```
+new MM.Extent(north, west, south, east)
+```
+Create an extent bounded by **north**, **west**, **south** and **east** edges.
+
+```
+new MM.Extent(northWest, southEast)
+```
+Create an extent containing both **northWest** and **southEast** [locations](#Location).
+
+<a name="Extent.north"></a>
+### north `extent.north`
+The northern edge of the extent. The [constructor](#Extent) compares northern and southern values and selects the higher of the two as its `north`.
+<a name="Extent.south"></a>
+### south `extent.south`
+The southern edge of the extent. The [constructor](#Extent) compares northern and southern values and selects the lower of the two as its `south`.
+<a name="Extent.east"></a>
+### east `extent.east`
+The eastern edge of the extent. The [constructor](#Extent) compares eastern and western values and selects the higher of the two as its `east`.
+<a name="Extent.west"></a>
+### west `extent.west`
+The western edge of the extent. The [constructor](#Extent) compares eastern and western bounds and selects the lower of the two values as its `west`.
+
+<a name="Extent.northWest"></a>
+### northWest `extent.northWest()`
+Get the extent's northwest corner as a [Location](#Location).
+<a name="Extent.northEast"></a>
+### northEast `extent.northEast()`
+Get the extent's northeast corner as a [Location](#Location).
+<a name="Extent.southEast"></a>
+### southEast `extent.southEast()`
+Get the extent's southeast corner as a [Location](#Location).
+<a name="Extent.southWest"></a>
+### southWest `extent.southWest()`
+Get the extent's southwest corner as a [Location](#Location).
+<a name="Extent.center"></a>
+### center `extent.center()`
+Get the extent's center as a [Location](#Location).
+
+<a name="Extent.containsLocation"></a>
+### containsLocation `extent.containsLocation(lcoation)`
+Returns `true` if the **location** falls within the **extent**, otherwise `false`.
+
+```
+var extent = new MM.Extent(37.8, -122.5, 37.6, -122.3);
+var sf = new MM.Location(37.764, -122.419);
+var oakland = new MM.Location(37.804, -122.271);
+extent.containsLocation(sf); // true
+extent.containsLocation(oakland); // false
+```
+
+<a name="Extent.encloseLocation"></a>
+### encloseLocation `extent.encloseLocation(location)`
+Update the bounds of **extent** to include the provided **location**.
+
+```
+var extent = new MM.Extent(37.8, -122.5, 37.6, -122.3);
+var oakland = new MM.Location(37.804, -122.271);
+extent.encloseLocation(oakland);
+extent.containsLocation(oakland); // true
+```
+
+<a name="Extent.encloseLocations"></a>
+### encloseLocations `extent.encloseLocations(locations)`
+Update the bounds of **extent** to include the provided **locations** (an array of [Location](#Location) objects).
+
+<a name="Extent.encloseExtent"></a>
+### encloseExtent `extent.encloseExtent(otherExtent)`
+Update the bounds of **extent** to include the bounds of the **other extent**.
+
+<a name="Extent.setFromLocations"></a>
+### setFromLocations `extent.setFromLocations(locations)`
+Reset the bounds of the **extent** and enclose the provided **locations**.
+
+<a name="Extent.copy"></a>
+### copy `extent.copy()`
+Copy the **extent** and its `north`, `south`, `east` and `west` values.
+
+<a name="Extent.toArray"></a>
+### toArray `extent.toArray()`
+Returns a two-element array containing the **extent**'s [northwest](#Extent.northWest) and [southeast](#Extent.southEast) locations.
+
+<a name="Extent.fromString"></a>
+### Extent.fromString `MM.Extent.fromString(str)`
+Parse a string in the format `"north,west,south,east"` into a new Extent object.
+
+<a name="Extent.fromArray"></a>
+### Extent.fromArray `MM.Extent.fromArray(locations)`
+Create a new Extent object from an array of [Location](#Location) objects.
+
+
+<a name="Point"></a>
+## MM.Point
+Point objects represent *x* and *y* coordinates on the screen, such as a [map's dimensions](#Map.dimensions) and the position of mouse or touch interactions.
+
+```
+new MM.Point(x, y)
+```
+Create a new Point object with **x** and **y** coordinates. `parseFloat()` is used to convert string values to numbers. The resulting object has `x` and `y` properties.
+
+Point objects can be used with [pointLocation](#Map.pointLocation) to determine the [geographic coordinates](#Location) of a point on the  screen inside a map. For instance:
+
+```
+// define the map's dimensions
+var size = new MM.Point(640, 480);
+// create a map without any layers or event handlers
+var map = new MM.Map("map", [], size, []);
+// zoom to San Francisco
+map.setCenterZoom(new MM.Location(37.764, -122.419), 8);
+// get the geographic coordinates of the bottom right corner
+var southEast = map.pointLocation(size);
+```
+
+And vice-versa, you can use [locationPoint](#Map.locationPoint) to get the screen position of a geographic coordinate:
+
+```
+var oakland = new MM.Location(37.804, -122.271);
+var point = map.locationPoint(oakland);
+// do something with point.x and point.y
+```
+
+### Point.distance `MM.Point.distance(a, b)`
+Compute the [Euclidian distance](http://en.wikipedia.org/wiki/Euclidean_distance) between two Point objects.
+
+### Point.interpolate `MM.Point.interpolate(a, b, t)`
+Compute the point on a straight line between points **a** and **b** at normal distance **t**, a number between `0` and `1`. (If `t == .5` the point will be halfway between **a** and **b**.)
+
+<a name="Coordinate"></a>
+## MM.Coordinate
+Coordinate objects are used internally by ModestMaps to model the surface of the Earth in  [Google's spherical Mercator projection](http://en.wikipedia.org/wiki/Google_Maps#Map_projection), which flattens the globe into a square, or *tile*. Coordinate objects represent points within that tile at different `zoom` levels, with `column` and `row` properties indicating their *x* and *y* positions, respectively. Each round number column and row within a zoom level represents a 256-pixel squar [...]
+
+```
+new Coordinate(row, column, zoom)
+```
+
+<a name="Coordinate.zoom"></a>
+### zoom `coordinate.zoom`
+Coordinates are always expressed relative to a specific **zoom** level. At zoom `0`, the Earth fits into a single square tile, `Coordinate(0, 0, 0)`. With each increase in zoom, every tile is divided into 4 parts, so at zoom level `1` the Earth becomes 4 tiles; at zoom level `2` it becomes 16. Coordinates can be converted to different zoom levels with [zoomTo](#Coordinate.zoomTo).
+
+<a name="Coordinate.column"></a>
+### column `coordinate.column`
+A Coordinate's `column` represents a tile's relative *x* position at its zoom level. At zoom `0` there is one column. With each increase in zoom, the number of columns doubles, so at zoom `1` there are two (`0 >= column < 2`), at zoom `2` there are four (`0 >= column < 4`), and so on.
+
+<a name="Coordinate.row"></a>
+### row `coordinate.row`
+A Coordinate's `row` represents a tile's relative *y* position at its zoom level. At zoom `0` there is only one tile. With each increase in zoom, the number of rows doubles, so at zoom `1` there are two (`0 >= row < 2`), at zoom `2` there are four (`0 >= row < 4`), and so on.
+
+<a name="Coordinate.copy"></a>
+### copy `coordinate.copy()`
+Copy the **coordinate**'s `zoom`, `row` and `column` properties into a new **Coordinate** object.
+
+<a name="Coordinate.container"></a>
+### container `coordinate.container()`
+Create a Coordinate object that contains **coordinate** by flooring its `zoom`, `column` and `row` properties. This is the actual "tile" coordinate.
+
+<a name="Coordinate.zoomTo"></a>
+### zoomTo `coordinate.zoomTo(zoom)`
+Copy **coordinate** and adjust its `row` and `column` properties to match the new **zoom** level.
+
+<a name="Coordinate.zoomBy"></a>
+### zoomBy `coordinate.zoomBy(zoomOffset)`
+Zoom **coordinate** by the the specified **zoom offset** and return a new Coordinate object.
+
+<a name="Coordinate.up"></a>
+### up `coordinate.up()`
+Get the Coordinate above **coordinate**.
+
+<a name="Coordinate.right"></a>
+### right `coordinate.right()`
+Get the Coordinate to the right of **coordinate**.
+
+<a name="Coordinate.down"></a>
+### down `coordinate.down()`
+Get the Coordinate below **coordinate**.
+
+<a name="Coordinate.left"></a>
+### left `coordinate.left()`
+Get the Coordinate to the left of **coordinate**.
+
+<a name="Coordinate.toKey"></a>
+### toKey `coordinate.toKey()`
+Generate a string key for the **coordinate**, e.g. `"(1,1,5)"` (`"zoom,row,column"`).
+
+<a name="Coordinate.toString"></a>
+### toString `coordinate.toString()`
+Format the **coordinate** as a human-readable string, e.g. `"(5,4 @ 1)"` (`("row,column @ zoom")`)
+
+
+<a name="Coordinate-pre-projecting"></a>
+### Pre-projecting
+Coordinate are also useful for "pre-projecting" [locations](#Location). Because conversions between screen and geographic coordinates are more computationally expensive than conversions between screen and tile coordinates, you may wish to do the [Location to Coordinate](#Map.locationCoordinate) conversion once then do [Coordinate to Point](#Map.coordinatePoint) conversions subsequently. For example:
+
+```
+var map = new MM.Map("map", …);
+var sfLocation = new MM.Location(37.764, -122.419);
+var sfCoordinate = map.locationCoordinate(sfLocation);
+// assuming there is an "sf" element, with CSS positon: absolute
+var marker = map.parent.appendChild(document.getElementById("sf"));
+map.addCallback("drawn", function() {
+    var point = map.coordinatePoint(sfCoordinate);
+    marker.style.left = point.x + "px";
+    marker.style.top = point.y + "px";
+});
+```
+
+In this example, `map.coordinatePoint(sfCoordinate)` will be much faster than calling `map.locationPoint(sfLocation)` each time the map is redrawn. You probably won't notice the performance gain with one marker, but you certainly will with hundreds.
+
+
+
+<a name="TemplatedLayer"></a>
+## MM.TemplatedLayer
+The **TemplatedLayer** class provides a simple interface for making layers with templated tile URLs.
+
+```
+new MM.TemplatedLayer(templateURL [, subdomains])
+```
+Create a layer in which each tile image's URL is a variation of the **URL template** and optional list of **subdomains**.
+
+You can learn more about templated tile URLs in the [Template](#Template) reference. Here are some examples:
+
+```
+var toner = new MM.TemplatedLayer("http://tile.stamen.com/toner/{Z}/{X}/{Y}.png");
+var bing = new MM.TemplatedLayer("http://ecn.t0.tiles.virtualearth.net/tiles/r{Q}?" +
+    "g=689&mkt=en-us&lbl=l1&stl=h");
+var osm = new MM.TemplatedLayer("http://tile.openstreetmap.org/{Z}/{X}/{Y}.png");
+```
+
+
+<a name="Layer"></a>
+## MM.Layer
+Map layers are where map imagery (including but not limited to tiles) gets rendered. The **Layer** class does all of the heavy lifting to determine which tiles are visible at any given moment, loads them if necessary, then adds them to the DOM and positions them on screen.
+
+```
+new MM.Layer(provider [, parent])
+```
+Create a new map layer that uses a **provider**, optionally specifying a custom **parent** element (or container). A layer's **provider** is an instance of the [MapProvider](#MapProvider) class, which converts [tile coordinates](#Coordinate) into image URLs. This example provides [Placehold.it](http://placehold.it/) URLs that list the tile coordinates:
+
+```
+var provider = new MM.MapProvider(function(coord) {
+    return "http://placehold.it/256x256&text=" +
+        [coord.zoom, coord.column, coord.row].join("/");
+});
+var layer = new MM.Layer(provider);
+map.addLayer(layer);
+```
+
+The [Template](#Template) class simplifies generating image URLs for tile servers with popular template formats.
+
+<a name="Layer.getProvider"></a>
+### getProvider `layer.getProvider()`
+Get the layer's current provider.
+
+<a name="Layer.setProvider"></a>
+### setProvider `layer.setProvider()`
+Set the layer's current provider.
+
+<a name="Layer.destroy"></a>
+### destroy `layer.destroy()`
+Destroy the layer, removing all of its tiles from memory and removing its **parent** element from the map.
+
+<a name="Layer.draw"></a>
+### draw `layer.draw()`
+Redraw the layer by loading, unloading, adding, removing, and repositioning tile images as appropriate. Changing the provider triggers a **draw**.
+
+<a name="Layer.requestRedraw"></a>
+### requestRedraw `layer.requestRedraw()`
+Request a layer redraw in 1 second. This works just like [Map.redraw](#Map.redraw).
+
+
+<a name="MapProvider"></a>
+## MM.MapProvider
+Map providers convert [tile coordinates](#Coordinate) to image URLs. If your image tiles come in either [XYZ](#TemplateProvider-XYZ) or [quadkey](#TemplateProvider-Quadkey) formats, you should use the [TemplateProvider](#TemplateProvider) class.
+
+```
+new MM.MapProvider(getTileUrl)
+```
+
+**MapProvider** is an abstract class, meaning that it is meant to be [extended](#MM.extend). The constructor takes a function as its only argument, which is expected to return an image URL (or `null`) for a given [tile coordinate](#Coordinate). This example emulates the behavior of [Template](#Template) using a static URL template:
+
+```
+var provider = new MM.MapProvider(function(coord) {
+    return "http://tile.stamen.com/toner/{Z}/{X}/{Y}.png"
+        .replace("{Z}", coord.zoom)
+        .replace("{X}", coord.column)
+        .replace("{Y}", coord.row);
+});
+// Coordinate(row, col, zoom)
+provider.getTile(new MM.Coordinate(1, 2, 3));
+// returns: "http://tile.stamen.com/toner/3/2/1.png"
+```
+
+Map providers expose the following interface to [Layer](#Layer) objects:
+
+<a name="MapProvider.getTile"></a>
+### getTile `provider.getTile(tileCoord)`
+Generates a tile URL or DOM element for the given **tile coordinate**. If the returned value is a string, an `<img>` element is created. Otherwise, if truthy, the return value is assumed to be a DOM element.
+
+For instance, you could create a map provider that generates `<canvas>` elements for each tile by customizing **getTile** like so (note that in this case, your tiles will need to either reside on the same server or be served with the appropriate [CORS headers](http://enable-cors.org/)):
+
+```
+var myProvider = new MM.MapProvider(function(coord) {
+    return "path/to/tiles/" +
+        [coord.zoom, coord.column, coord.row].join("/") +
+        ".png";
+});
+myProvider.getTile = function(coord) {
+    var url = this.getTileUrl(coord);
+    if (url) {
+        var canvas = document.createElement("canvas");
+        canvas.width = canvas.height = 256;
+        var ctx = canvas.getContext("2d"),
+            img = new Image();
+        img.onload = function() {
+            canvas.drawImage(img);
+        };
+        img.src = url;
+        return canvas;
+    }
+};
+```
+
+NOTE: Because layers cache elements returned by this function, there is no guarantee that **getTile** will be called subsequently after a call to **releaseTile** with the same tile coordinate. If your provider needs to be notified of "re-added" tiles (ones that are generated once, released, then added again from the cache), it should implement [reAddTile](#MapProvider.reAddTile).
+
+<a name="MapProvider.getTileUrl"></a>
+### getTileUrl `provider.getTileUrl(tileCoord)`
+Get the URL of the tile with the provided **coordinate**. In the abstract **MapProvider** class, **getTile** and **getTileUrl**
+
+<a name="MapProvider.releaseTile"></a>
+### releaseTile `provider.releaseTile(tileCoord)`
+Clean up any resources required to display the **tile coordinate's** corresponding tile image or element. This is probably only necessary if your provider maintains references (such as a list or numeric reference count) to tiles generated by **getTile**.
+
+<a name="MapProvider.reAddTile"></a>
+### reAddTile `provider.reAddTile(tileCoord)`
+If a provider implements the **reAddTile** method, cached tiles will be passed to this function so that the provider can know about the re-addition of tiles revived from the layer cache.
+
+
+<a name="Template"></a>
+## MM.Template
+ModestMap's Template class extends [MapProvider](#MapProvider), and converts [tile coordinates](#Coordinate) to image URLs using a standard template format. These are the same constructor arguments as in [TemplatedLayer](#TemplatedLayer):
+
+```
+new MM.Template(urlTemplate [, subdomains])
+```
+Create a new templated provider based on the specified **URL template**, and an optional array of **subdomain** replacements. URL templates may contain the following placeholders:
+
+<a name="Template.XYZ"></a>
+### X, Y, Z `http://example.com/tiles/{Z}/{X}/{Y}.ext`
+In an **XYZ** template, the `{X}`, `{Y}` and `{Z}` placeholders are replaced with each [tile's](#Coordinate) `column`, `row` and `zoom` properties, respectively.
+
+```
+var toner = new MM.Template("http://tile.stamen.com/toner/{Z}/{X}/{Y}.png");
+```
+
+<a name="Template.quadkey"></a>
+### Quadkey `http://example.com/tiles/{Q}.ext`
+In a **quadkey** template, the `{Q}` placeholder is replaced with each [tile's](#Coordinate) [quadkey string](http://msdn.microsoft.com/en-us/library/bb259689.aspx). These are found on Microsoft's [Bing Maps](http://www.bing.com/maps/) (previously VirtualEarth) tile servers:
+
+```
+var bingBase = "http://ecn.t0.tiles.virtualearth.net/tiles/r{Q}?";
+var bing = new MM.Template(bingBase + "g=689&mkt=en-us&lbl=l1&stl=h");
+```
+
+<a name="Template.subdomains"></a>
+### Subdomains `http://{S}.example.com/...`
+If an array of **subdomains** is passed to the Template constructor, tile URLs will substitute a predictable selection from the array for any `{S}` placeholder (e.g., the first one gets `subdomains[0]`, the second gets `subdomains[1]`, etc.). Many tile servers support loading via multiple subdomains, e.g.:
+
+```
+var osm = new MM.Template("http://{S}.tile.openstreetmap.org/{Z}/{X}/{Y}.png",
+    ["a", "b", "c", "d"]);
+var bing = new MM.Template("http://ecn.t{S}.tiles.virtualearth.net/tiles/r{Q}" +
+    "?g=689&mkt=en-us&lbl=l1&stl=h",
+    [1, 2, 3, 4]);
+var terrain = new MM.Template("http://{S}.tile.stamen.com/terrain/{Z}/{X}/{Y}.png",
+    "a b c d".split(" "));
+```
+
+**Multiple subdomains may drastically speed up your maps!** Most browsers place limits on the number of URLs that can be loaded simultaneously from each domain. Using two subdomains in effect doubles the number of image tiles that can load at the same time.
+
+NOTE: `{S}` placeholders need not *necessarily* refer to subdomains. You could, for instance, vary the entire hostname of each tile, like so:
+
+```
+var template = new MM.TemplateProvider("http://{S}/tiles/{Z}/{X}/{Y}.png",
+    ["example.com", "example.org", "example.net"]);
+```
+
+
+## Package Utilities
+These are provided as useful shortcuts, often used to provide cross-browser compatibility.
+
+### MM.extend `MM.extend(childClass, parentClass)`
+Extend the `prototype` of **child class** with previously unspecified methods from the **parent class**'s `prototype`. This is how you extend classes in ModestMaps:
+
+```
+var MyLayer = function(provider) {
+    // do something MyLayer-specific
+    // then call the Layer constructor
+    MM.Layer.call(this, provider);
+};
+
+MyLayer.prototype = {
+    getTile: function(coord) {
+        // do something cool here
+    }
+};
+
+MM.extend(MyLayer, MM.Layer);
+```
+
+### MM.coerceLayer `MM.coerceLayer(layerish)`
+Coerce the provided **layerish** string or object into a [Layer](#Layer), according to the following rules:
+
+1. If **layerish** is a string, return a new [TemplatedLayer](#TemplatedLayer) with **layerish** as the URL template.
+2. If **layerish** has a `draw` function, assume that it's a [Layer](#Layer) instance and return it.
+3. Otherwise, assume that it's a [MapProvider](#MapProvider) and return a new [Layer](#Layer) with it as the constructor argument: `new MM.Layer(layerish)`.
+
+### MM.addEvent `MM.addEvent(element, eventType, listener)`
+Adds the **listener** to the provided **DOM element** for the given **event type**. In browsers that support [DOM Level 2 events](http://www.w3.org/TR/DOM-Level-2-Events/), this calls `element.addEventListener(eventType, listener, false)`. In older versions of Internet Explorer, this uses `element.attachEvent()`.
+
+```
+var link = document.getElementById("null-island"),
+    nullIsland = new MM.Location(0, 0);
+MM.addEvent(link, "click", function(e) {
+    map.setCenterZoom(nullIsland, 12);
+    return MM.cancelEvent(e);
+});
+```
+
+You can remove event listeners with [MM.removeEvent](#MM.removeEvent).
+
+### MM.removeEvent `MM.removeEvent(element, eventType, listener)`
+Removes the **listener** from **element** for the given **event type**.
+
+```
+MM.removeEvent(link, "click", onClick);
+```
+
+### MM.cancelEvent `MM.cancelEvent(event)`
+Does whatever is necessary to cancel the provided DOM event and returns `false`. This is useful for preventing the default behavior or `click` events, e.g.:
+
+```
+var zoomIn = document.getElementById("zoom-in");
+MM.addEvent(zoomIn, "click", function(e) {
+    map.zoomIn();
+    return MM.cancelEvent(e);
+});
+```
+
+### MM.getStyle `MM.getStyle(element, property)`
+Get the **element**'s [computed style](https://developer.mozilla.org/en/DOM/window.getComputedStyle) of the named **CSS property**.
+
+```
+var bgcolor = MM.getStyle(map.parent, "background-color");
+```
+
+### MM.moveElement `MM.moveElement(element, point)`
+Updates the CSS properties of **element** so that it appears at the absolute position **point**. If available, this function uses [CSS transforms](http://www.w3.org/TR/css3-transforms/) (which are often hardware accelerated, and thus faster than traditional `top` and `left` properties).
+
+
+```
+var marker = document.getElementById("marker"),
+    sf = new MM.Location(37.764, -122.419);
+map.addCallback("drawn", function() {
+    var point = map.locationPoint(sf);
+    MM.moveElement(marker, point);
+});
+```
+
+(See the section on [pre-projecting](#Coordinate-pre-projecting) for a slightly better way of doing this.)
+
+### MM.getFrame `MM.getFrame(frameCallback)`
+This is a stand-in for [requestAnimationFrame](https://developer.mozilla.org/en/DOM/window.requestAnimationFrame), a feature of modern browsers that calls the **frame callback** function as often as possible without affecting page repainting.
+
+### MM.transformProperty `MM.transformProperty`
+The name of the property used by the running browser to provide [CSS transforms](http://www.w3.org/TR/css3-transforms/).
+
+### MM.matrixString `MM.matrixString(point)`
+Convert **point** into a CSS transform-compatible matrix string.
+
diff --git a/doc/css/main.css b/doc/css/main.css
new file mode 100644
index 0000000..1d80002
--- /dev/null
+++ b/doc/css/main.css
@@ -0,0 +1,206 @@
+
+body {
+  font-size: 14px;
+  line-height: 22px;
+  font-family: Helvetica Neue, Helvetica, Arial;
+  background: #f4f4f4 url(docs/images/background.png);
+}
+
+#toc {
+  font-family: "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, sans-serif !important;
+  background: #fff;
+  position: fixed;
+  top: 0; left: 0; bottom: 0;
+  width: 200px;
+  overflow-y: auto;
+  overflow-x: hidden;
+  -webkit-overflow-scrolling: touch;
+  padding: 15px 0 30px 30px;
+  border-right: 1px solid #bbb;
+  box-shadow: 0 0 20px #ccc; -webkit-box-shadow: 0 0 20px #ccc; -moz-box-shadow: 0 0 20px #ccc;
+}
+  #toc h1 {
+    color: black;
+    font-size: inherit;
+    line-height: inherit;
+    font-weight: bold;
+    margin: 0;
+  }
+  #toc .version {
+      margin: 0;
+  }
+  #toc h2 {
+    color: black;
+    font-size: inherit;
+    line-height: inherit;
+    font-weight: bold;
+    margin: 15px 0 0 0;
+  }
+    #toc .version {
+      font-size: 10px;
+      font-weight: normal;
+    }
+
+  #toc ul {
+    font-size: 11px;
+    line-height: 14px;
+    margin: 5px 0 0 0;
+    padding-left: 16px;
+    list-style-type: disc;
+    font-family: Lucida Grande;
+  }
+    #toc ul li {
+      cursor: pointer;
+      margin: 0 0 3px 0;
+    }
+      #toc ul li a {
+        text-decoration: none;
+        color: black;
+      }
+        #toc ul li a:hover {
+          text-decoration: underline;
+        }
+
+#content {
+  position: relative;
+  width: 550px;
+  margin: 40px 0 50px 260px;
+}
+
+div.run {
+  position: absolute;
+  right: 15px;
+  width: 26px; height: 18px;
+  background: url('docs/images/arrows.png') no-repeat -26px 0;
+}
+  div.run:active {
+    background-position: -51px 0;
+  }
+
+p, div.container ul {
+  margin: 0 0 25px 0;
+  width: 550px;
+}
+  p.warning {
+    font-size: 12px;
+    line-height: 18px;
+    font-style: italic;
+  }
+  div.container ul {
+    list-style: circle;
+    padding-left: 15px;
+    font-size: 13px;
+    line-height: 18px;
+  }
+    div.container ul li {
+      margin-bottom: 10px;
+    }
+    div.container ul.small {
+      font-size: 12px;
+    }
+a, a:visited {
+  color: #444;
+}
+a:active, a:hover {
+  color: #000;
+}
+
+a img {
+  border: 0;
+}
+
+h1, h2, h3, h4, h5, h6 {
+  margin: 20px 0 5px 0;
+}
+  h2 {
+    font-size: 22px;
+  }
+b.header {
+  font-size: 18px;
+  line-height: 35px;
+}
+span.alias {
+  font-size: 14px;
+  font-style: italic;
+  margin-left: 20px;
+}
+table {
+  margin: 15px 0 0; padding: 0;
+}
+  tr, td {
+    margin: 0; padding: 0;
+  }
+    td {
+      padding: 0px 15px 5px 0;
+    }
+code, pre, tt {
+  font-family: Monaco, Consolas, "Lucida Console", monospace;
+  font-size: 12px;
+  font-weight: normal;
+  line-height: 18px;
+  font-style: normal;
+  padding: 0px 3px;
+  background: #fff;
+  border: 1px solid #ddd;
+}
+  pre {
+    font-size: 12px;
+    padding: 2px 0 2px 15px;
+    border: 0;
+    border-left: 4px solid #bbb;
+    margin: 0px 0 25px;
+  }
+
+  pre code {
+      border: 0;
+      padding: 0;
+      background: none;
+  }
+
+ at media only screen and (-webkit-min-device-pixel-ratio: 1.5) and (max-width: 640px),
+      only screen and (-o-min-device-pixel-ratio: 3/2) and (max-width: 640px),
+      only screen and (min-device-pixel-ratio: 1.5) and (max-width: 640px) {
+  img {
+    max-width: 290px;
+  }
+  div#sidebar {
+    -webkit-overflow-scrolling: initial;
+    position: relative;
+    width: 90%;
+    height: 120px;
+    left: 0;
+    top: -7px;
+    padding: 10px 0 10px 30px;
+    border: 0;
+  }
+  img#logo {
+    width: auto; 
+    height: auto;
+  }
+  div.container {
+    margin: 0;
+    width: 100%;
+  }
+  p, div.container ul {
+    max-width: 98%;
+    overflow-x: scroll;
+  }
+  table {
+    position: relative;
+  }
+    tr:first-child td {
+      padding-bottom: 25px;
+    }
+    td.text {
+      padding: 0;
+      position: absolute;
+      left: 0;
+      top: 48px;
+    }
+    tr:last-child td.text {
+      top: 122px;
+    }
+  pre {
+    overflow: scroll;
+  }
+}
diff --git a/doc/end.html b/doc/end.html
new file mode 100644
index 0000000..64584ee
--- /dev/null
+++ b/doc/end.html
@@ -0,0 +1,3 @@
+        </div>
+    </body>
+</html>
diff --git a/doc/index.html b/doc/index.html
new file mode 100644
index 0000000..1a3dad6
--- /dev/null
+++ b/doc/index.html
@@ -0,0 +1,1350 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>modestmaps.js v3.3.4</title>
+        <style type="text/css">
+            @import url(css/main.css);
+        </style>
+    </head>
+    <body>
+        <div id="toc">
+            <h1>modestmaps.js</h1>
+            <p class="version"><code>v3.3.4</code></p>
+<h2><a href="#source">Getting the Source</a></h2>
+<h2><a href="#quick-start">Quick Start</a></h2>
+<ul>
+<li><a href="#quick.map">Making a map</a></li>
+<li><a href="#quick.moving">Moving around</a></li>
+<li><a href="#quick.layers">Working with layers</a></li>
+</ul>
+<h2><a href="#Map">Map</a></h2>
+<ul>
+<li><a href="#Map.getCenter">getCenter</a></li>
+<li><a href="#Map.setCenter">setCenter</a></li>
+<li><a href="#Map.getZoom">getZoom</a></li>
+<li><a href="#Map.setZoom">setZoom</a></li>
+<li><a href="#Map.setCenterZoom">setCenterZoom</a></li>
+<li><a href="#Map.getExtent">getExtent</a></li>
+<li><a href="#Map.setExtent">setExtent</a></li>
+<li><a href="#Map.zoomIn">zoomIn</a></li>
+<li><a href="#Map.zoomOut">zoomOut</a></li>
+<li><a href="#Map.zoomBy">zoomBy</a></li>
+<li><a href="#Map.zoomByAbout">zoomByAbout</a></li>
+<li><a href="#Map.panBy">panBy</a></li>
+<li><a href="#Map.panLeft">panLeft</a></li>
+<li><a href="#Map.panRight">panRight</a></li>
+<li><a href="#Map.panUp">panUp</a></li>
+<li><a href="#Map.panDown">panDown</a></li>
+<li><a href="#Map.center">center</a></li>
+<li><a href="#Map.zoom">zoom</a></li>
+<li><a href="#Map.extent">extent</a></li>
+<li><a href="#Map.addLayer">addLayer</a></li>
+<li><a href="#Map.removeLayer">removeLayer</a></li>
+<li><a href="#Map.getLayers">getLayers</a></li>
+<li><a href="#Map.getLayerAt">getLayerAt</a></li>
+<li><a href="#Map.setLayerAt">setLayerAt</a></li>
+<li><a href="#Map.insertLayerAt">insertLayerAt</a></li>
+<li><a href="#Map.removeLayerAt">removeLayerAt</a></li>
+<li><a href="#Map.swapLayersAt">swapLayersAt</a></li>
+<li><a href="#Map.addCallback">addCallback</a></li>
+<li><a href="#Map.removeCallback">removeCallback</a></li>
+<li><a href="#Map.pointLocation">pointLocation</a></li>
+<li><a href="#Map.pointCoordinate">pointCoordinate</a></li>
+<li><a href="#Map.locationPoint">locationPoint</a></li>
+<li><a href="#Map.locationCoordinate">locationCoordinate</a></li>
+<li><a href="#Map.coordinateLocation">coordinateLocation</a></li>
+<li><a href="#Map.coordinatePoint">coordinatePoint</a></li>
+<li><a href="#Map.setZoomRange">setZoomRange</a></li>
+<li><a href="#Map.setSize">setSize</a></li>
+<li><a href="#Map.autoSize">autoSize</a></li>
+<li><a href="#Map.dimensions">dimensions</a></li>
+<li><a href="#Map.draw">draw</a></li>
+<li><a href="#Map.requestRedraw">requestRedraw</a></li>
+<li><a href="#Map.parent">parent</a></li>
+<li><a href="#Map.coordinate">coordinate</a></li>
+<li><a href="#Map.coordLimits">coordLimits</a></li>
+<li><a href="#Map.tileSize">tileSize</a></li>
+</ul>
+<h2><a href="#Location">Location</a></h2>
+<ul>
+<li><a href="#Location.lat">latitude</a> and <a href="#Location.lon">longitude</a></li>
+<li><a href="#Location.fromString">Location.fromString</a></li>
+<li><a href="#Location.fromString">Location.distance</a></li>
+<li><a href="#Location.fromString">Location.interpolate</a></li>
+<li><a href="#Location.fromString">Location.bearing</a></li>
+</ul>
+<h2><a href="#Extent">Extent</a></h2>
+<ul>
+<li><a href="#Extent.north">north</a>, <a href="#Extent.east">east</a>, <a href="#Extent.south">south</a> and <a href="#Extent.west">west</a></li>
+<li><a href="#Extent.northWest">northWest</a></li>
+<li><a href="#Extent.northEast">northEast</a></li>
+<li><a href="#Extent.southEast">southEast</a></li>
+<li><a href="#Extent.southWest">southWest</a></li>
+<li><a href="#Extent.containsLocation">containsLocation</a></li>
+<li><a href="#Extent.encloseLocation">encloseLocation</a></li>
+<li><a href="#Extent.encloseLocations">encloseLocations</a></li>
+<li><a href="#Extent.encloseExtent">encloseExtent</a></li>
+<li><a href="#Extent.setFromLocations">setFromLocations</a></li>
+<li><a href="#Extent.copy">copy</a></li>
+<li><a href="#Extent.toArray">toArray</a></li>
+<li><a href="#Extent.fromString">Extent.fromString</a></li>
+<li><a href="#Extent.fromArray">Extent.fromArray</a></li>
+</ul>
+<h2><a href="#Point">Point</a></h2>
+<ul>
+<li><a href="#Point.distance">Point.distance</a></li>
+<li><a href="#Point.interpolate">Point.interpolate</a></li>
+</ul>
+<h2><a href="#Coordinate">Coordinate</a></h2>
+<ul>
+<li><a href="#Coordinate.zoom">zoom</a>, <a href="#Coordinate.column">column</a> and <a href="#Coordinate.row">row</a></li>
+<li><a href="#Coordinate.zoomTo">zoomTo</a></li>
+<li><a href="#Coordinate.zoomBy">zoomBy</a></li>
+<li><a href="#Coordinate.container">container</a></li>
+<li><a href="#Coordinate.up">up</a></li>
+<li><a href="#Coordinate.down">down</a></li>
+<li><a href="#Coordinate.left">left</a></li>
+<li><a href="#Coordinate.right">right</a></li>
+<li><a href="#Coordinate.toKey">toKey</a></li>
+<li><a href="#Coordinate.toString">toString</a></li>
+</ul>
+<h2><a href="#TemplatedLayer">TemplatedLayer</a></h2>
+<h2><a href="#Layer">Layer</a></h2>
+<ul>
+<li><a href="#Layer.getProvider">getProvider</a></li>
+<li><a href="#Layer.setProvider">setProvider</a></li>
+<li><a href="#Layer.draw">draw</a></li>
+<li><a href="#Layer.requestRedraw">requestRedraw</a></li>
+</ul>
+<h2><a href="#Template">Template</a></h2>
+<h2><a href="#MapProvider">MapProvider</a></h2>
+<ul>
+<li><a href="#MapProvider.getTile">getTile</a></li>
+<li><a href="#MapProvider.getTileUrl">getTileUrl</a></li>
+<li><a href="#MapProvider.releaseTile">releaseTile</a></li>
+<li><a href="#MapProvider.reAddTile">reAddTile</a></li>
+</ul>
+
+        </div>
+
+        <div id="content" class="container">
+<h1>modestmaps.js</h1>
+<p>Modest Maps is a bare-bones geographic map display and interaction library. It was designed and conceived by <a href="http://www.tom-carden.co.uk/">Tom Carden</a>, tweaked by <a href="http://mike.teczno.com/">Michal Migurski</a>, and is maintained and hacked on primarily by <a href="http://macwright.org/">Tom MacWright</a> and <a href="http://github.com/shawnbot">Shawn Allen</a>.
+
+</p>
+<p><a name="source"></a>
+</p>
+<h2>Getting the Source</h2>
+<p>You can get modestmaps.js by cloning <a href="https://github.com/modestmaps/modestmaps-js/">the github repo</a> or downloading it:
+
+</p>
+<ul>
+<li><a href="https://github.com/modestmaps/modestmaps-js/zipball/v3.3.4">modestmaps.js-v3.3.4.zip</a> (zip archive)</li>
+<li><a href="../modestmaps.js">modestmaps.js</a> (source JavaScript, 100K)</li>
+<li><a href="../modestmaps.min.js">modestmaps.min.js</a> (minified JavaScript, 36K)</li>
+</ul>
+<p>After you've downloaded it, you can include by putting this <code><script></code> tag into the <code><head></code> of your HTML document:
+
+</p>
+<pre><code><script type="text/javascript" src="modestmaps.js"></script></code></pre>
+<p><a name="quick-start"></a>
+</p>
+<h2>Quick Start</h2>
+<p><a name="quick.map"></a>
+</p>
+<h3>Making a Map</h3>
+<p>Making a map is easy. First, you'll need a place for your map in the HTML:
+
+</p>
+<pre><code><div id="map"></div></code></pre>
+<p>Then, add a script below:
+
+</p>
+<pre><code><script type="text/javascript">
+var tiles = new MM.TemplatedLayer("http://tile.stamen.com/toner/{Z}/{X}/{Y}.png");
+var size = new MM.Point(640, 480);
+var map = new MM.Map("map", tiles, size);
+</script></code></pre>
+<p>This will create a map showing <a href="http://maps.stamen.com/toner/">Stamen's toner tiles</a> in a 640x480-pixel area. See the docs below for more info on <a href="#TemplatedLayer">layers</a> and <a href="#Map.dimensions">map dimensions</a>.
+
+</p>
+<p>If you want the size of your map to be determined by CSS, you can style your div like so:
+
+</p>
+<pre><code>#map {
+    height: 500px;
+}</code></pre>
+<p>Then, leave off the <code>size</code> argument to the constructor:
+
+</p>
+<pre><code><script type="text/javascript">
+var tiles = new MM.TemplatedLayer("http://tile.stamen.com/toner/{Z}/{X}/{Y}.png");
+var map = new MM.Map("map", tiles);
+</script></code></pre>
+<p>For more info on resizing, see the <a href="#Map.constructor">Map constructor</a> and <a href="#Map.autoSize">autoSize</a> docs.
+
+</p>
+<p><a name="quick.moving"></a>
+</p>
+<h3>Moving Around</h3>
+<p>Once you've got your map initialized, you can move it around the world. Geographic locations in modestmaps.js are modeled with the <a href="#Location">Location</a> class, which is called with <em>latitude</em> and <em>longitude</em> values:
+
+</p>
+<pre><code>var oakland = new MM.Location(37.804, -122.271);</code></pre>
+<p>Once you've got a location, you can tell the map to center on it by calling <a href="#Map.setCenter">setCenter</a>:
+
+</p>
+<pre><code>// center on Oakland, California
+map.setCenter(oakland);
+// center on Amsterdam, Netherlands
+map.setCenter(new MM.Location(52.3702157, 4.8951679));</code></pre>
+<p>You can get the current center of the map with <a href="#Map.getCenter">getCenter</a>. You can also modify the visible area by setting its <a href="#Extent">extent</a>, which is defined by two or more locations. <a href="#Map.setCenter">Setting</a> a map's extent adjusts its center and zoom level so that the rectangular bounding box surrounding the locations is entirely visible:
+
+</p>
+<pre><code>var oakland = new MM.Location(37.804, -122.271),
+    amsterdam = new MM.Location(52.3702157, 4.8951679);
+var extent = new MM.Extent(oakland, amsterdam);
+map.setExtent(extent)</code></pre>
+<p>You can change the map's zoom level with the <a href="#Map.zoomIn">zoomIn</a>, <a href="#Map.zoomOut">zoomOut</a> and <a href="#Map.zoomTo">zoomTo</a> methods:
+
+</p>
+<pre><code>map.zoomIn();   // increase zoom by 1
+map.zoomOut();  // decrease zoom by 1
+map.zoomTo(12); // zoom to level 12</code></pre>
+<p><a name="quick.layers"></a>
+</p>
+<h3>Working with Layers</h3>
+<p>One popular feature of many online maps is a "hybrid" style, which overlays satellite imagery with graphical labels. You can achieve this effect in modestmaps.js by creating two <a href="#TemplatedLayer">tile layers</a>, and passing them both to the <a href="#Map.constructor">Map constructor</a> as an array:
+
+</p>
+<pre><code>var baseURL = "http://tile.stamen.com/",
+    watercolor = new MM.TemplatedLayer(baseURL + "watercolor/{Z}/{X}/{Y}.jpg"),
+    labels = new MM.TemplatedLayer(baseURL + "toner-labels/{Z}/{X}/{Y}.jpg");
+var map = new MM.Map("map", [watercolor, labels]);</code></pre>
+<p>Or you can create the map with one layer, then add the overlay later:
+
+</p>
+<pre><code>var map = new MM.Map("map", watercolor);
+map.addLayer(labels);</code></pre>
+<p>See the <a href="#Map.addLayer">addLayer</a> docs and the <a href="#TemplatedLayer">TemplatedLayer</a> class reference for more on working with layers.
+
+</p>
+<p><a name="Map"></a>
+</p>
+<h2>MM.Map</h2>
+<p>The Map class is the core of <strong>modestmaps.js</strong>.
+
+</p>
+<pre><code>new MM.Map(parent [, layerOrLayers [, dimensions [, eventHandlers]]])</code></pre>
+<p>Creates a new map inside the given <strong>parent</strong> element, containing the specified <strong>layers</strong>, optionally with the specified <strong>dimensions</strong> in pixels and custom <strong>event handlers</strong>. The <strong>Map</strong> constructor arguments are described in detail below:
+
+</p>
+<h4>parent</h4>
+<p>The parent <a href="http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-745549614">element</a> of the map. This is typically a <code>String</code> indicating the ID of the element:
+
+</p>
+<pre><code>var map = new MM.Map("map", []);</code></pre>
+<p>You can also provide an element reference:
+
+</p>
+<pre><code>var firstDiv = new MM.Map(document.querySelector("div.map"), ...);</code></pre>
+<p>Here's a pattern for inserting maps into a series of classed elements, using <a href="https://developer.mozilla.org/en/DOM/document.getElementsByClassName">document.getElementsByClassName</a>:
+
+</p>
+<pre><code>var elements = document.getElementsByClassName("map"),
+    maps = [];
+for (var i = 0; i < elements.length; i++) {
+  maps[i] = new MM.Map(elements[i], ...);
+}</code></pre>
+<p>If an element with the provided ID string is not found, an exception is raised.
+
+</p>
+<p>If <strong>parent</strong> is not an object or a string, an exception is raised.
+
+
+</p>
+<h4>layerOrLayers</h4>
+<p>Either a single <a href="#Layer">layer</a> object or an array of layer objects. Layer objects should either be instances of the <a href="#Layer">Layer</a> class or implement the <a href="#Layer-Interface">Layer interface</a>.
+
+</p>
+<p>Here's an example of a map with two tile layers, from maps.stamen.com:
+
+</p>
+<pre><code>var baseURL = "http://tile.stamen.com/",
+    watercolor = new MM.TemplatedLayer(baseURL + "watercolor/{Z}/{X}/{Y}.png"),
+    labels = new MM.TemplatedLayer(baseURL + "toner-labels/{Z}/{X}/{Y}.png");
+var map = new MM.Map("map", [watercolor, labels]);</code></pre>
+<p>NOTE: Before modestmaps.js <em>v3.1.1</em>, an exception was raised if <strong>layerOrLayers</strong> was not an object or an array.
+
+
+</p>
+<h4>dimensions</h4>
+<p>An optional map size in pixels, expressed as a <a href="#Point">Point</a> object.
+
+</p>
+<pre><code>var size = new MM.Point(512, 512);
+var map = new MM.Map("map", [], size);
+console.log("map size:", map.dimensions.x, "x", map.dimensions.y);</code></pre>
+<p>If <strong>dimensions</strong> is <code>null</code> or <code>undefined</code>, the dimensions are derived from
+the width and height of the parent element, and the map's <a href="#Map.autoSize">autoSize</a>
+flag is set to <code>true</code>.
+
+</p>
+<p>Empty <code><div></code> elements have no intrinsic height, so if you don't provide dimensions you'll need to provide the map's parent height in CSS (either inline or in a stylesheet).
+
+</p>
+<h4>eventHandlers</h4>
+<p>An optional array of interaction event handlers, which should implement the <a href="#EventHandler-Interface">EventHandler interface</a>. If no handlers are provided (<code>eventHandlers === undefined</code>), the map is initialized with <a href="#MouseHandler">mouse</a> and <a href="#TouchHandler">touch</a> handlers.
+
+</p>
+<p>For instance, to create a map without scroll wheel zooming (which is enabled by default), you can provide <a href="#DragHandler">drag</a>, and <a href="#DoubleClickHandler">double-click</a> handlers:
+
+</p>
+<pre><code>var map = new MM.Map("map", [], null, [
+  new MM.DragHandler(),
+  new MM.DoubleClickHandler()
+]);</code></pre>
+<p>The <a href="#TouchHandler">touch</a> handler provides panning and zooming in touch-enabled browsers:
+
+</p>
+<pre><code>var map = new MM.Map("map", [], null, [
+  new MM.TouchHandler()
+]);</code></pre>
+<p>To initialize the map without any interaction handlers, specify <strong>eventHandlers</strong> as <code>null</code> or an empty array (<code>[]</code>).
+
+
+</p>
+<p><a name="Map.getCenter"></a>
+</p>
+<h3>getCenter <code>map.getCenter()</code></h3>
+<p>Get the map's center <strong>location</strong>.
+
+</p>
+<pre><code>var center = map.getCenter();
+console.log("center latitude:", center.lat, "+ longitude:", center.lon);</code></pre>
+<p><a name="Map.setCenter"></a>
+</p>
+<h3>setCenter <code>map.setCenter(location)</code></h3>
+<p>Set the map's center <strong>location</strong>.
+
+</p>
+<pre><code>var center = new MM.Location(37.764, -122.419);
+map.setCenter(center);</code></pre>
+<p><a name="Map.getZoom"></a>
+</p>
+<h3>getZoom <code>map.getZoom()</code><a name="Map.getZoom"></a></h3>
+<p>Get the map's <strong>zoom level</strong>.
+
+</p>
+<pre><code>var zoom = map.getZoom();
+console.log("zoom level:", zoom);</code></pre>
+<p><a name="Map.setZoom"></a>
+</p>
+<h3>setZoom <code>map.setZoom(zoom)</code></h3>
+<p>Set the map's <strong>zoom level</strong>.
+
+</p>
+<pre><code>map.setZoom(17);</code></pre>
+<p><a name="Map.setCenterZoom"></a>
+</p>
+<h3>setCenterZoom <code>map.setCenterZoom(location, zoom)</code></h3>
+<p>Set the map's center <strong>location</strong> and <strong>zoom level</strong>.
+
+</p>
+<pre><code>map.setCenterZoom(new MM.Location(37.764, -122.419), 17);</code></pre>
+<p><a name="Map.getExtent"></a>
+</p>
+<h3>getExtent <code>map.getExtent()</code></h3>
+<p>Get the visible extent (bounds) of the map as an <a href="#Extent">Extent</a> object.
+
+</p>
+<pre><code>var extent = map.getExtent();
+console.log("northwest location:", extent.northWest());
+console.log("southeast location:", extent.southEast());</code></pre>
+<p><a name="Map.setExtent"></a>
+</p>
+<h3>setExtent <code>map.setExtent(extent [, precise])</code></h3>
+<p>Modify the center and zoom of the map so that the provided <strong>extent</strong> is visible. If <strong>precise</strong> is <code>true</code>, resulting zoom levels may be fractional. (By default, the map's zoom level is rounded down to keep tile images from blurring.)
+
+</p>
+<pre><code>var extent = new MM.Extent(
+  new MM.Location(55.679, 12.584),
+  new MM.Location(55.668, 12.607)
+);
+map.setExtent(extent, true);</code></pre>
+<p>NOTE: For historical reasons, <strong>setExtent</strong> also accepts an array of <a href="#Location">Location</a> objects, which are converted using <a href="#Extent.fromArray">Extent.fromArray</a>.
+
+</p>
+<p><a name="Map.zoomIn"></a>
+</p>
+<h3>zoomIn <code>map.zoomIn()</code></h3>
+<p>Increase the map's zoom level by one.
+
+</p>
+<p><a name="Map.zoomOut"></a>
+</p>
+<h3>zoomOut <code>map.zoomOut()</code></h3>
+<p>Decrease the map's zoom level by one.
+
+</p>
+<p><a name="Map.zoomBy"></a>
+</p>
+<h3>zoomBy <code>map.zoomBy(zoomOffset)</code></h3>
+<p>Zoom the map by the provided <strong>offset</strong>. Positive offsets zoom in; negative offsets zoom out.
+
+</p>
+<pre><code>// this is the equivalent of calling map.zoomIn() twice:
+map.zoomBy(2);</code></pre>
+<p><a name="Map.zoomByAbout"></a>
+</p>
+<h3>zoomByAbout <code>map.zoomByAbout(zoomOffset, point)</code></h3>
+<p>Zoom the map by the provided <strong>zoom offset</strong> from a <strong>point</strong> on the screen in pixels. Positive offsets zoom in; negative offsets zoom out. This function is used by <a href="#DoubleClickHandler">DoubleClickHandler</a> to zoom in on the point where the map is double-clicked.
+
+</p>
+<pre><code>// zoom in on the upper left corner
+var point = new MM.Point(0, 0);
+map.zoomByAbout(1, point);</code></pre>
+<p><a name="Map.panBy"></a>
+</p>
+<h3>panBy <code>map.panBy(x, y)</code></h3>
+<p>Pan the map by the specified <strong>x</strong> and <strong>y</strong> distance in pixels. Positive values move the map right and down, respectively; negative values move the map left and up.
+
+</p>
+<pre><code>// pan 500 pixels to the right
+map.panBy(500, 0);
+// pan 200 pixels up
+map.panBy(0, -200);</code></pre>
+<p><a name="Map.panLeft"></a>
+</p>
+<h3>panLeft <code>map.panLeft()</code></h3>
+<p><a name="Map.panRight"></a>
+</p>
+<h3>panRight <code>map.panRight()</code></h3>
+<p><a name="Map.panUp"></a>
+</p>
+<h3>panUp <code>map.panUp()</code></h3>
+<p><a name="Map.panDown"></a>
+</p>
+<h3>panDown <code>map.panDown()</code></h3>
+<p>Pan the map to the left, right, up or down by 100 pixels. To vary the offset distance, use <a href="#Map.panBy">panBy</a>.
+
+</p>
+<p><a name="Map.getLayers"></a>
+</p>
+<h3>getLayers <code>map.getLayers()</code></h3>
+<p>Get a copy of the map's layers array.
+
+</p>
+<pre><code>var layers = map.getLayers();
+var base = layers[0];</code></pre>
+<p><a name="Map.getLayerAt"></a>
+</p>
+<h3>getLayerAt <code>map.getLayerAt(index)</code></h3>
+<p>Get the layer at a specific <strong>index</strong>. The first layer is at index <code>0</code>, the second at <code>1</code>, etc.
+
+</p>
+<pre><code>var map = new MM.Map(...);
+var base = map.getLayerAt(0);
+base.parent.id = "base";</code></pre>
+<p><a name="Map.addLayer"></a>
+</p>
+<h3>addLayer <code>map.addLayer(layer)</code></h3>
+<p>Add <strong>layer</strong> to the map's <a href="#Map.layers">layer stack</a>]. This triggers a <a href="#Map.redraw">redraw</a>.
+
+</p>
+<pre><code>var layer = new MM.TemplatedLayer("http://tile.stamen.com/toner-lines/{Z}/{X}/{Y}.png");
+map.addLayer(layer);</code></pre>
+<p><a name="Map.removeLayer"></a>
+</p>
+<h3>removeLayer <code>map.removeLayer(layer)</code></h3>
+<p>Remove <strong>layer</strong> from the map's <a href="#Map.layers">layer stack</a>.
+
+</p>
+<p><a name="Map.setLayerAt"></a>
+</p>
+<h3>setLayerAt <code>map.setLayerAt(index, newLayer)</code></h3>
+<p>Replace the existing layer at <strong>index</strong> with the <strong>new layer</strong>.
+
+</p>
+<pre><code>var layer = new MM.TemplatedLayer("http://tile.stamen.com/toner/{Z}/{X}/{Y}.png");
+map.setLayerAt(0, layer);</code></pre>
+<p><a name="Map.insertLayerAt"></a>
+</p>
+<h3>insertLayerAt <code>map.insertLayerAt(index, layer)</code></h3>
+<p>Insert a <strong>layer</strong> at the provided <strong>index</strong>.
+
+</p>
+<pre><code>// let's assume the map has 2 layers already
+var layer = new MM.TemplatedLayer("http://tile.stamen.com/toner-lines/{Z}/{X}/{Y}.png");
+map.insertLayerAt(1, layer);
+// (now it has 3, with our new layer at index 1)</code></pre>
+<p><a name="Map.removeLayerAt"></a>
+</p>
+<h3>removeLayerAt <code>map.removeLayerAt(index)</code></h3>
+<p>Remove the layer at the provided index.
+
+</p>
+<pre><code>// remove the second layer
+map.removeLayerAt(1);</code></pre>
+<p><a name="Map.swapLayersAt"></a>
+</p>
+<h3>swapLayersAt <code>map.swapLayersAt(indexA, indexB)</code></h3>
+<p>Swap the z-index (order) or the layers at <strong>indexA</strong> and <strong>indexB</strong>.
+
+</p>
+<pre><code>// swap the bottom and top layers
+var bottom = 0,
+    top = map.getLayers().length - 1;
+map.swapLayersAt(bottom, top);</code></pre>
+<p><a name="Map.pointLocation"></a>
+</p>
+<h3>pointLocation <code>map.pointLocation(screenPoint)</code></h3>
+<p>Convert a <strong>point on the screen</strong> to a <a href="#Location">location</a> (a point on the Earth).
+
+</p>
+<p><a name="Map.pointCoordinate"></a>
+</p>
+<h3>pointCoordinate <code>map.pointCoordinate(screenPoint)</code></h3>
+<p>Convert a <strong>point on the screen</strong> to a <a href="#Coordinate">tile coordinate</a>.
+
+</p>
+<p><a name="Map.locationPoint"></a>
+</p>
+<h3>locationPoint <code>locationPoint(location)</code></h3>
+<p>Convert a <strong>location</strong> (a point on the Earth) to a <a href="#Point">point</a> on the screen.
+
+</p>
+<p><a name="Map.locationCoordinate"></a>
+</p>
+<h3>locationCoordinate <code>map.locationCoordinate(location)</code></h3>
+<p>Convert a <strong>location</strong> (a point on the Earth) to a <a href="#Coordinate">tile coordinate</a>.
+
+</p>
+<p><a name="Map.coordinateLocation"></a>
+</p>
+<h3>coordinateLocation <code>map.coordinateLocation(coord)</code></h3>
+<p>Convert a <a href="#Coordinate">tile coordinate</a> to a <a href="#Location">location</a> (a point on the Earth).
+
+</p>
+<p><a name="Map.coordinatePoint"></a>
+</p>
+<h3>coordinatePoint <code>map.coordinatePoint(coord)</code></h3>
+<p>Convert a <a href="#Coordinate">tile coordinate</a> to a <a href="#Point">point</a> on the screen.
+
+</p>
+<p><a name="Map.setZoomRange"></a>
+</p>
+<h3>setZoomRange <code>map.setZoomRange(minZoom, maxZoom)</code></h3>
+<p>Set the map's <strong>minimum</strong> and <strong>maximum</strong> zoom levels. This function modifies the zoom levels of the map's <a href="#Map.coordLimits">coordLimits</a>.
+
+</p>
+<p><a name="Map.setSize"></a>
+</p>
+<h3>setSize <code>map.setSize(dimensions)</code></h3>
+<p>Set the map's <strong>dimensions</strong> in pixels. If the map's <a href="#Map.autoSize">autoSize</a> flag is <code>true</code>, setting the size manually sets <strong>autoSize</strong> to <code>false</code> and prevents further automatic resizing.
+
+</p>
+<pre><code>map.setSize(new MM.Point(640, 480));</code></pre>
+<p>NOTE: The map's current size is available in its <a href="#Map.dimensions">dimensions</a> property.
+
+</p>
+<p><a name="Map.addCallback"></a>
+</p>
+<h3>addCallback <code>map.addCallback(eventType, callback)</code></h3>
+<p>Add a <strong>callback function</strong> (listener) to the map for a specific <strong>event type</strong>. Callback functions always receive the map instance as their first argument; additional arguments differ by event type. See the <a href="#Map-events">events list</a> for supported types.
+
+</p>
+<pre><code>function onPanned(map, offset) {
+  console.log("panned by", offset[0], offset[1]);
+}
+
+map.addCallback("panned", onPanned);</code></pre>
+<p>You can remove callbacks with <a href="#Map.removeCallback">removeCallback</a>.
+
+</p>
+<p><a name="Map.removeCallback"></a>
+</p>
+<h3>removeCallback <code>map.removeCallback(eventType, callback)</code></h3>
+<p>Remove a <strong>callback function</strong> (listener) for the given <strong>event type</strong>. You can add callbacks with <a href="#Map.addCallback">addCallback</a>.
+
+</p>
+<pre><code>map.removeCallback("panned", onPanned);</code></pre>
+<p><a name="Map.draw"></a>
+</p>
+<h3>draw <code>map.draw()</code></h3>
+<p>Redraw the map and its layers. First, the map enforces its <a href="#Map.coordLimits">coordLimits</a> on its center and zoom. If <a href="#Map.autoSize">autoSize</a> is <code>true</code>, the map's dimensions are recalculated from its <a href="#Map.parent">parent</a>. Lastly, each of the map's layers is <a href="#Layer.draw">drawn</a>.
+
+</p>
+<p><a name="Map.requestRedraw"></a>
+</p>
+<h3>requestRedraw <code>map.requestRedraw()</code></h3>
+<p>Request a "lazy" call to <a href="#Map.draw">draw</a> in 1 second. This is useful if you're responding to lots of user input and know that you'll need to redraw the map <em>eventually</em>, but not immediately.
+
+</p>
+<p>Multiple calls to <strong>requestRedraw</strong> within 1 second of one another will be ignored, so this is a perfectly reasonable thing to do:
+
+</p>
+<pre><code>setInterval(function() {
+  map.requestRedraw();
+}, 100);</code></pre>
+<h2>Hybrid Methods</h2>
+<p>Hybrid methods behave differently depending on whether they receive arguments: The "getter" form (with no arguments) returns the current value, and the "setter" form sets it to the value provided then returns <code>this</code>, which makes function chaining possible (a la <a href="http://jquery.com">jQuery</a>, <a href="http://d3js.com">d3</a>, and <a href="http://polymaps.org">Polymaps</a>).
+
+</p>
+<p><a name="Map.center"></a>
+</p>
+<h3>center <code>map.center([location])</code></h3>
+<p><a href="#Map.getCenter">Get</a> or <a href="#Map.setCenter">set</a> the map's center <strong>location</strong>.
+
+</p>
+<pre><code>var center = map.center();
+center.lat += .1;
+map.center(center);</code></pre>
+<p><a name="Map.zoom"></a>
+</p>
+<h3>zoom <code>map.zoom([level])</code></h3>
+<p><a href="#Map.getZoom">Get</a> or <a href="#Map.setZoom">set</a> the map's <strong>zoom level</strong>.
+
+</p>
+<pre><code>var zoom = map.zoom();
+zoom -= 3;
+map.zoom(zoom);</code></pre>
+<p><a name="Map.extent"></a>
+</p>
+<h3>extent <code>map.extent([locationsOrExtent [, precise]])</code></h3>
+<p><a href="#Map.getZoom">Get</a> or <a href="#Map.setZoom">set</a> the map's extent. If <strong>precise</strong> is <code>true</code>, resulting zoom levels may be fractional.
+
+</p>
+<pre><code>// get the extent, check if it contains a location…
+var extent = map.extent(),
+    loc = new MM.Location(37.764, -122.419);
+if (!extent.containsLocation(loc)) {
+  // then enclose the location and set the map's new extent
+  extent.encloseLocation(loc);
+  map.extent(extent);
+}</code></pre>
+<h2>Map Properties</h2>
+<p><a name="Map.autoSize"></a>
+</p>
+<h3>autoSize <code>map.autoSize</code></h3>
+<p>The <strong>autoSize</strong> property is set to <code>true</code> if no dimensions are provided in the <a href="#Map">constructor</a>. When <strong>autoSize</strong> is <code>true</code>, the map's dimensions are recalculated (and the map is <a href="#Map.draw">redrawn</a>) <a href="https://developer.mozilla.org/en/DOM/window.onresize">on window resize</a>.
+
+</p>
+<p><a name="Map.coordinate"></a>
+</p>
+<h3>coordinate <code>map.coordinate</code></h3>
+<p>The map's current center <a href="#Coordinate">coordinate</a>.
+
+</p>
+<p><a name="Map.coordLimits"></a>
+</p>
+<h3>coordLimits <code>map.coordLimits</code></h3>
+<p>An array specifying the map's coordinate bounds, in which the first element defines the top left (northwest) and outermost zoom level, and the second defines the bottom right (southwest) and innermost zoom.
+
+</p>
+<p>You can adjust the minimum and maximum zoom levels of the map without affecting the bounds with <a href="#Map.setZoomRange">setZoomRange</a>.
+
+</p>
+<p><a name="Map.dimensions"></a>
+</p>
+<h3>dimensions <code>map.dimensions</code></h3>
+<p>The map's current dimensions, expressed as a <a href="#Point">Point</a>.
+
+</p>
+<pre><code>// the bottom right screen coordinate is also its southeast point
+var southEast = map.pointLocation(map.dimensions);</code></pre>
+<p><a name="Map.parent"></a>
+</p>
+<h3>parent <code>map.parent</code></h3>
+<p>The map's parent (container) DOM element.
+
+</p>
+<pre><code>map.parent.style.backgroundColor = "green";</code></pre>
+<p><a name="Map.projection"></a>
+</p>
+<h3>projection <code>map.projection</code></h3>
+<p>The map's projection, also known as Coordinate Reference System (CRS) or Spatial Reference System (SRS).
+
+</p>
+<p><a name="Map.tileSize"></a>
+</p>
+<h3>tileSize <code>map.tileSize</code></h3>
+<p>The pixel dimensions of the map's individual image tiles, expressed as a <a href="#Point">Point</a>. By default, tiles are <strong>256</strong> pixels square.
+
+</p>
+<pre><code>// you can use the tile size to estimate the number of tiles visible
+// at any given moment:
+var maxRows = Math.ceil(map.dimensions.x / map.tileSize.x);
+var maxCols = Math.ceil(map.dimensions.y / map.tileSize.y);
+var maxTiles = maxRows * maxCols;
+console.log("max tiles:", maxTiles);</code></pre>
+<p><a name="Map-events"></a>
+</p>
+<h2>Map Events</h2>
+<p>Map events are triggered when the map moves (either in response to a direct function call or indirectly, through user interaction with an event handlers) or is <a href="#Map.draw">drawn</a>. You can start and stop listening for map events with <a href="#Map.addCallback">addCallback</a> and <a href="#Map.removeCallback">removeCallback</a>:
+
+</p>
+<pre><code>function onDrawn(map) {
+  console.log("map drawn!");
+}
+
+// After this, the onDrawn will be called whenever the map changes.
+map.addCallback("drawn", onZoomed);
+// Later, remove the callback.
+map.removeCallback("drawn", onZoomed);</code></pre>
+<p><a name="Map-zoomed"></a>
+</p>
+<h3>"zoomed" <code>function(map, zoomOffset) { ... }</code></h3>
+<p>Fires when the <strong>map's</strong> zoom level changes, usually in response to <a href="#Map.zoomBy">zoomBy</a> or <a href="#Map.zoomByAbout">zoomByAbout</a>. Note that the <strong>zoom offset</strong> is the <em>difference</em> between the last zoom level and the new zoom level. You can query the map's current zoom level (rather than the offset) with <a href="#Map.getZoom">getZoom</a>.
+
+</p>
+<pre><code>map.addCallback("zoomed", function(map, zoomOffset) {
+  console.log("map zoomed by:", zoomOffset);
+});</code></pre>
+<p><a name="Map-panned"></a>
+</p>
+<h3>"panned" <code>function(map, panOffset) { ... }</code></h3>
+<p>Fires when the <strong>map</strong> is panned, and receives the <strong>pan offset</strong> (delta) in pixels as a two-element array (<code>[dx, dy]</code>).
+
+</p>
+<pre><code>map.addCallback("panned", function(map, panOffset) {
+  var dx = panOffset[0],
+      dy = panOffset[1];
+  console.log("map panned by x:", dx, "y:", dy);
+});</code></pre>
+<p><a name="Map-resized"></a>
+</p>
+<h3>"resized" <code>function(map, dimensions) { ... }</code></h3>
+<p>Fires when the <strong>map</strong> is resized, and receives the map's new <strong>dimensions</strong> as a <a href="#Point">Point</a> object.
+
+</p>
+<pre><code>map.addCallback("panned", function(map, dimensions) {
+  console.log("map dimensions:", dimensions.x, "y:", dimensions.y);
+});</code></pre>
+<p><a name="Map-extentset"></a>
+</p>
+<h3>"extentset" <code>function(map, locationsOrExtent) { ... }</code></h3>
+<p>Fires whenever the <strong>map's</strong> full extent is set, and receives the <a href="#Extent">Extent</a> or array of <a href="#Location">Location</a> objects provided to <a href="#Map.setExtent">setExtent</a> or <a href="#Map.extent">extent</a>.
+
+</p>
+<pre><code>map.addCallback("extentset", function(map, extent) {
+  // convert to an Extent instance if it's a Location array
+  if (extent instanceof Array) {
+    extent = MM.Extent.fromArray(extent);
+  }
+  console.log("map extent:", extent);
+});</code></pre>
+<p><a name="Map-drawn"></a>
+</p>
+<h3>"drawn" <code>function(map) { ... }</code></h3>
+<p>Fires whenever the <strong>map</strong> is <a href="#Map.draw">redrawn</a>.
+
+</p>
+<pre><code>map.addCallback("drawn", function(map) {
+  console.log("map drawn!");
+});</code></pre>
+<p><a name="Location"></a>
+</p>
+<h2>MM.Location</h2>
+<p>Location objects represent <a href="http://en.wikipedia.org/wiki/Geographic_coordinate_system">geographic coordinates</a> on the Earth's surface, expressed as degrees <em>latitude</em> and <em>longitude</em>. The constructor takes these two values as its arguments:
+
+</p>
+<pre><code>new MM.Location(latitude, longitude)</code></pre>
+<p>Locations are most often used when <a href="#Map.getCenter">getting</a> and <a href="#Map.setCenter">setting</a> the center of a <a href="#Map">map</a>. You can read the latitude and longitude of a Location by accessing its <code>lat</code> and <code>lon</code> properties, respectively:
+
+</p>
+<pre><code>var center = map.getCenter(),
+    latitude = center.lat,
+    longitude = center.lon;</code></pre>
+<p>Note that the <a href="#Map">Map</a> class doesn't store any references to Location objects internally. Both the <a href="#Map.getCenter">getCenter</a> and <a href="#Map.setCenter">setCenter</a> methods convert between geographic and <a href="#Coordinate">tile coordinate</a> systems, and return copies of objects rather than references. This means that changing the <code>lat</code> and <code>lon</code> properties of a Location object returned from <strong>getCenter</strong> won&#39 [...]
+
+</p>
+<p><a name="Location.lat"></a>
+</p>
+<h3>lat <code>location.lat</code></h3>
+<p>The location's <strong>latitude</strong>, or distance from the Earth's <a href="http://en.wikipedia.org/wiki/Prime_meridian">equator</a> in degrees. <code>-90</code> is at the bottom of the globe (the south pole in Antarctica), <code>0</code> is at the equator, and <code>90</code> is at the top (the north pole in the Arctic Ocean).
+
+</p>
+<p><strong>NOTE:</strong> Because ModestMaps uses a <a href="http://en.wikipedia.org/wiki/Mercator_projection">spherical Mercator projection</a>, points at Earth's extreme north and south poles become infinitely large and impossible to model. This limits the effective range of web maps to <code>±85º</code>, depending on zoom level. Setting a map's center to a Location with a latitude outside of this range will most likely have undesired consequences.
+
+</p>
+<p><a name="Location.lon"></a>
+</p>
+<h3>lon <code>location.lon</code></h3>
+<p>The location's <strong>longitude</strong>, or distance from the <a href="http://en.wikipedia.org/wiki/Prime_meridian">prime meridian</a> in degrees. Positive values are east of the prime meridian (towards Asia); negative values are west (towards North America). <code>±180</code> degrees is near the <a href="http://en.wikipedia.org/wiki/International_Date_Line">international date line</a>. Longitude values outside of the <code>[-180, 180]</code> range "wrap", so a longitu [...]
+
+</p>
+<p><a name="Location.fromString"></a>
+</p>
+<h3>Location.fromString <code>MM.Location.fromString(str)</code></h3>
+<p>Parse a string in the format <code>"lat,lon"</code> into a new Location object.
+
+</p>
+<p><a name="Location.distance"></a>
+</p>
+<h3>Location.distance <code>MM.Location.distance(a, b, earthRadius)</code></h3>
+<p>Get the physical distance (along a <a href="http://en.wikipedia.org/wiki/Great_circle">great circle</a>) between locations <strong>a</strong> and <strong>b</strong>, assuming an optional <strong>Earth radius</strong>:
+
+</p>
+<ul>
+<li><code>6378000</code> meters (the default)</li>
+<li><code>3963.1</code> "statute" miles</li>
+<li><code>3443.9</code> nautical miles</li>
+<li><code>6378</code> kilometers</li>
+</ul>
+<p><a name="Location.interpolate"></a>
+</p>
+<h3>Location.interpolate <code>MM.Location.interpolate(a, b, t)</code></h3>
+<p>Interpolate along a <a href="http://en.wikipedia.org/wiki/Great_circle">great circle</a> between locations <strong>a</strong> and <strong>b</strong> at bias point <strong>t</strong> (a number between 0 and 1).
+
+</p>
+<p><a name="Location.bearing"></a>
+</p>
+<h3>Location.bearing <code>MM.Location.bearing(a, b)</code></h3>
+<p>Determine the direction in degrees between locations <strong>a</strong> and <strong>b</strong>. Note that bearing direction is not constant along significant <a href="http://en.wikipedia.org/wiki/Great_circle">great cirlce</a> arcs.
+
+</p>
+<p><a name="Location-location"></a>
+</p>
+<h3>A warning about the <code>location</code> variable name</h3>
+<p>Because browsers reserve the <code>window.location</code> variable for <a href="https://developer.mozilla.org/en/DOM/window.location">information</a> about the current page location, we suggest using variable names other than <code>location</code> to avoid namespace conflicts. <code>center</code> and <code>loc</code> are good alternatives.
+
+
+</p>
+<p><a name="Extent"></a>
+</p>
+<h2>MM.Extent</h2>
+<p>Extent objects represent rectangular geographic bounding boxes, and are identified by their <code>north</code>, <code>south</code>, <code>east</code> and <code>west</code> bounds. North and south bounds are expressed as degrees <a href="#Location.lat">latitude</a>; east and west bounds are degrees <a href="#Location.lon">longitude</a>. The constructor takes two forms:
+
+</p>
+<pre><code>new MM.Extent(north, west, south, east)</code></pre>
+<p>Create an extent bounded by <strong>north</strong>, <strong>west</strong>, <strong>south</strong> and <strong>east</strong> edges.
+
+</p>
+<pre><code>new MM.Extent(northWest, southEast)</code></pre>
+<p>Create an extent containing both <strong>northWest</strong> and <strong>southEast</strong> <a href="#Location">locations</a>.
+
+</p>
+<p><a name="Extent.north"></a>
+</p>
+<h3>north <code>extent.north</code></h3>
+<p>The northern edge of the extent. The <a href="#Extent">constructor</a> compares northern and southern values and selects the higher of the two as its <code>north</code>.
+<a name="Extent.south"></a>
+</p>
+<h3>south <code>extent.south</code></h3>
+<p>The southern edge of the extent. The <a href="#Extent">constructor</a> compares northern and southern values and selects the lower of the two as its <code>south</code>.
+<a name="Extent.east"></a>
+</p>
+<h3>east <code>extent.east</code></h3>
+<p>The eastern edge of the extent. The <a href="#Extent">constructor</a> compares eastern and western values and selects the higher of the two as its <code>east</code>.
+<a name="Extent.west"></a>
+</p>
+<h3>west <code>extent.west</code></h3>
+<p>The western edge of the extent. The <a href="#Extent">constructor</a> compares eastern and western bounds and selects the lower of the two values as its <code>west</code>.
+
+</p>
+<p><a name="Extent.northWest"></a>
+</p>
+<h3>northWest <code>extent.northWest()</code></h3>
+<p>Get the extent's northwest corner as a <a href="#Location">Location</a>.
+<a name="Extent.northEast"></a>
+</p>
+<h3>northEast <code>extent.northEast()</code></h3>
+<p>Get the extent's northeast corner as a <a href="#Location">Location</a>.
+<a name="Extent.southEast"></a>
+</p>
+<h3>southEast <code>extent.southEast()</code></h3>
+<p>Get the extent's southeast corner as a <a href="#Location">Location</a>.
+<a name="Extent.southWest"></a>
+</p>
+<h3>southWest <code>extent.southWest()</code></h3>
+<p>Get the extent's southwest corner as a <a href="#Location">Location</a>.
+<a name="Extent.center"></a>
+</p>
+<h3>center <code>extent.center()</code></h3>
+<p>Get the extent's center as a <a href="#Location">Location</a>.
+
+</p>
+<p><a name="Extent.containsLocation"></a>
+</p>
+<h3>containsLocation <code>extent.containsLocation(lcoation)</code></h3>
+<p>Returns <code>true</code> if the <strong>location</strong> falls within the <strong>extent</strong>, otherwise <code>false</code>.
+
+</p>
+<pre><code>var extent = new MM.Extent(37.8, -122.5, 37.6, -122.3);
+var sf = new MM.Location(37.764, -122.419);
+var oakland = new MM.Location(37.804, -122.271);
+extent.containsLocation(sf); // true
+extent.containsLocation(oakland); // false</code></pre>
+<p><a name="Extent.encloseLocation"></a>
+</p>
+<h3>encloseLocation <code>extent.encloseLocation(location)</code></h3>
+<p>Update the bounds of <strong>extent</strong> to include the provided <strong>location</strong>.
+
+</p>
+<pre><code>var extent = new MM.Extent(37.8, -122.5, 37.6, -122.3);
+var oakland = new MM.Location(37.804, -122.271);
+extent.encloseLocation(oakland);
+extent.containsLocation(oakland); // true</code></pre>
+<p><a name="Extent.encloseLocations"></a>
+</p>
+<h3>encloseLocations <code>extent.encloseLocations(locations)</code></h3>
+<p>Update the bounds of <strong>extent</strong> to include the provided <strong>locations</strong> (an array of <a href="#Location">Location</a> objects).
+
+</p>
+<p><a name="Extent.encloseExtent"></a>
+</p>
+<h3>encloseExtent <code>extent.encloseExtent(otherExtent)</code></h3>
+<p>Update the bounds of <strong>extent</strong> to include the bounds of the <strong>other extent</strong>.
+
+</p>
+<p><a name="Extent.setFromLocations"></a>
+</p>
+<h3>setFromLocations <code>extent.setFromLocations(locations)</code></h3>
+<p>Reset the bounds of the <strong>extent</strong> and enclose the provided <strong>locations</strong>.
+
+</p>
+<p><a name="Extent.copy"></a>
+</p>
+<h3>copy <code>extent.copy()</code></h3>
+<p>Copy the <strong>extent</strong> and its <code>north</code>, <code>south</code>, <code>east</code> and <code>west</code> values.
+
+</p>
+<p><a name="Extent.toArray"></a>
+</p>
+<h3>toArray <code>extent.toArray()</code></h3>
+<p>Returns a two-element array containing the <strong>extent</strong>'s <a href="#Extent.northWest">northwest</a> and <a href="#Extent.southEast">southeast</a> locations.
+
+</p>
+<p><a name="Extent.fromString"></a>
+</p>
+<h3>Extent.fromString <code>MM.Extent.fromString(str)</code></h3>
+<p>Parse a string in the format <code>"north,west,south,east"</code> into a new Extent object.
+
+</p>
+<p><a name="Extent.fromArray"></a>
+</p>
+<h3>Extent.fromArray <code>MM.Extent.fromArray(locations)</code></h3>
+<p>Create a new Extent object from an array of <a href="#Location">Location</a> objects.
+
+
+</p>
+<p><a name="Point"></a>
+</p>
+<h2>MM.Point</h2>
+<p>Point objects represent <em>x</em> and <em>y</em> coordinates on the screen, such as a <a href="#Map.dimensions">map's dimensions</a> and the position of mouse or touch interactions.
+
+</p>
+<pre><code>new MM.Point(x, y)</code></pre>
+<p>Create a new Point object with <strong>x</strong> and <strong>y</strong> coordinates. <code>parseFloat()</code> is used to convert string values to numbers. The resulting object has <code>x</code> and <code>y</code> properties.
+
+</p>
+<p>Point objects can be used with <a href="#Map.pointLocation">pointLocation</a> to determine the <a href="#Location">geographic coordinates</a> of a point on the  screen inside a map. For instance:
+
+</p>
+<pre><code>// define the map's dimensions
+var size = new MM.Point(640, 480);
+// create a map without any layers or event handlers
+var map = new MM.Map("map", [], size, []);
+// zoom to San Francisco
+map.setCenterZoom(new MM.Location(37.764, -122.419), 8);
+// get the geographic coordinates of the bottom right corner
+var southEast = map.pointLocation(size);</code></pre>
+<p>And vice-versa, you can use <a href="#Map.locationPoint">locationPoint</a> to get the screen position of a geographic coordinate:
+
+</p>
+<pre><code>var oakland = new MM.Location(37.804, -122.271);
+var point = map.locationPoint(oakland);
+// do something with point.x and point.y</code></pre>
+<h3>Point.distance <code>MM.Point.distance(a, b)</code></h3>
+<p>Compute the <a href="http://en.wikipedia.org/wiki/Euclidean_distance">Euclidian distance</a> between two Point objects.
+
+</p>
+<h3>Point.interpolate <code>MM.Point.interpolate(a, b, t)</code></h3>
+<p>Compute the point on a straight line between points <strong>a</strong> and <strong>b</strong> at normal distance <strong>t</strong>, a number between <code>0</code> and <code>1</code>. (If <code>t == .5</code> the point will be halfway between <strong>a</strong> and <strong>b</strong>.)
+
+</p>
+<p><a name="Coordinate"></a>
+</p>
+<h2>MM.Coordinate</h2>
+<p>Coordinate objects are used internally by ModestMaps to model the surface of the Earth in  <a href="http://en.wikipedia.org/wiki/Google_Maps#Map_projection">Google's spherical Mercator projection</a>, which flattens the globe into a square, or <em>tile</em>. Coordinate objects represent points within that tile at different <code>zoom</code> levels, with <code>column</code> and <code>row</code> properties indicating their <em>x</em> and <em>y</em> positions, respectively. Each roun [...]
+
+</p>
+<pre><code>new Coordinate(row, column, zoom)</code></pre>
+<p><a name="Coordinate.zoom"></a>
+</p>
+<h3>zoom <code>coordinate.zoom</code></h3>
+<p>Coordinates are always expressed relative to a specific <strong>zoom</strong> level. At zoom <code>0</code>, the Earth fits into a single square tile, <code>Coordinate(0, 0, 0)</code>. With each increase in zoom, every tile is divided into 4 parts, so at zoom level <code>1</code> the Earth becomes 4 tiles; at zoom level <code>2</code> it becomes 16. Coordinates can be converted to different zoom levels with <a href="#Coordinate.zoomTo">zoomTo</a>.
+
+</p>
+<p><a name="Coordinate.column"></a>
+</p>
+<h3>column <code>coordinate.column</code></h3>
+<p>A Coordinate's <code>column</code> represents a tile's relative <em>x</em> position at its zoom level. At zoom <code>0</code> there is one column. With each increase in zoom, the number of columns doubles, so at zoom <code>1</code> there are two (<code>0 >= column < 2</code>), at zoom <code>2</code> there are four (<code>0 >= column < 4</code>), and so on.
+
+</p>
+<p><a name="Coordinate.row"></a>
+</p>
+<h3>row <code>coordinate.row</code></h3>
+<p>A Coordinate's <code>row</code> represents a tile's relative <em>y</em> position at its zoom level. At zoom <code>0</code> there is only one tile. With each increase in zoom, the number of rows doubles, so at zoom <code>1</code> there are two (<code>0 >= row < 2</code>), at zoom <code>2</code> there are four (<code>0 >= row < 4</code>), and so on.
+
+</p>
+<p><a name="Coordinate.copy"></a>
+</p>
+<h3>copy <code>coordinate.copy()</code></h3>
+<p>Copy the <strong>coordinate</strong>'s <code>zoom</code>, <code>row</code> and <code>column</code> properties into a new <strong>Coordinate</strong> object.
+
+</p>
+<p><a name="Coordinate.container"></a>
+</p>
+<h3>container <code>coordinate.container()</code></h3>
+<p>Create a Coordinate object that contains <strong>coordinate</strong> by flooring its <code>zoom</code>, <code>column</code> and <code>row</code> properties. This is the actual "tile" coordinate.
+
+</p>
+<p><a name="Coordinate.zoomTo"></a>
+</p>
+<h3>zoomTo <code>coordinate.zoomTo(zoom)</code></h3>
+<p>Copy <strong>coordinate</strong> and adjust its <code>row</code> and <code>column</code> properties to match the new <strong>zoom</strong> level.
+
+</p>
+<p><a name="Coordinate.zoomBy"></a>
+</p>
+<h3>zoomBy <code>coordinate.zoomBy(zoomOffset)</code></h3>
+<p>Zoom <strong>coordinate</strong> by the the specified <strong>zoom offset</strong> and return a new Coordinate object.
+
+</p>
+<p><a name="Coordinate.up"></a>
+</p>
+<h3>up <code>coordinate.up()</code></h3>
+<p>Get the Coordinate above <strong>coordinate</strong>.
+
+</p>
+<p><a name="Coordinate.right"></a>
+</p>
+<h3>right <code>coordinate.right()</code></h3>
+<p>Get the Coordinate to the right of <strong>coordinate</strong>.
+
+</p>
+<p><a name="Coordinate.down"></a>
+</p>
+<h3>down <code>coordinate.down()</code></h3>
+<p>Get the Coordinate below <strong>coordinate</strong>.
+
+</p>
+<p><a name="Coordinate.left"></a>
+</p>
+<h3>left <code>coordinate.left()</code></h3>
+<p>Get the Coordinate to the left of <strong>coordinate</strong>.
+
+</p>
+<p><a name="Coordinate.toKey"></a>
+</p>
+<h3>toKey <code>coordinate.toKey()</code></h3>
+<p>Generate a string key for the <strong>coordinate</strong>, e.g. <code>"(1,1,5)"</code> (<code>"zoom,row,column"</code>).
+
+</p>
+<p><a name="Coordinate.toString"></a>
+</p>
+<h3>toString <code>coordinate.toString()</code></h3>
+<p>Format the <strong>coordinate</strong> as a human-readable string, e.g. <code>"(5,4 @ 1)"</code> (<code>("row,column @ zoom")</code>)
+
+
+</p>
+<p><a name="Coordinate-pre-projecting"></a>
+</p>
+<h3>Pre-projecting</h3>
+<p>Coordinate are also useful for "pre-projecting" <a href="#Location">locations</a>. Because conversions between screen and geographic coordinates are more computationally expensive than conversions between screen and tile coordinates, you may wish to do the <a href="#Map.locationCoordinate">Location to Coordinate</a> conversion once then do <a href="#Map.coordinatePoint">Coordinate to Point</a> conversions subsequently. For example:
+
+</p>
+<pre><code>var map = new MM.Map("map", …);
+var sfLocation = new MM.Location(37.764, -122.419);
+var sfCoordinate = map.locationCoordinate(sfLocation);
+// assuming there is an "sf" element, with CSS positon: absolute
+var marker = map.parent.appendChild(document.getElementById("sf"));
+map.addCallback("drawn", function() {
+    var point = map.coordinatePoint(sfCoordinate);
+    marker.style.left = point.x + "px";
+    marker.style.top = point.y + "px";
+});</code></pre>
+<p>In this example, <code>map.coordinatePoint(sfCoordinate)</code> will be much faster than calling <code>map.locationPoint(sfLocation)</code> each time the map is redrawn. You probably won't notice the performance gain with one marker, but you certainly will with hundreds.
+
+
+
+</p>
+<p><a name="TemplatedLayer"></a>
+</p>
+<h2>MM.TemplatedLayer</h2>
+<p>The <strong>TemplatedLayer</strong> class provides a simple interface for making layers with templated tile URLs.
+
+</p>
+<pre><code>new MM.TemplatedLayer(templateURL [, subdomains])</code></pre>
+<p>Create a layer in which each tile image's URL is a variation of the <strong>URL template</strong> and optional list of <strong>subdomains</strong>.
+
+</p>
+<p>You can learn more about templated tile URLs in the <a href="#Template">Template</a> reference. Here are some examples:
+
+</p>
+<pre><code>var toner = new MM.TemplatedLayer("http://tile.stamen.com/toner/{Z}/{X}/{Y}.png");
+var bing = new MM.TemplatedLayer("http://ecn.t0.tiles.virtualearth.net/tiles/r{Q}?" +
+    "g=689&mkt=en-us&lbl=l1&stl=h");
+var osm = new MM.TemplatedLayer("http://tile.openstreetmap.org/{Z}/{X}/{Y}.png");</code></pre>
+<p><a name="Layer"></a>
+</p>
+<h2>MM.Layer</h2>
+<p>Map layers are where map imagery (including but not limited to tiles) gets rendered. The <strong>Layer</strong> class does all of the heavy lifting to determine which tiles are visible at any given moment, loads them if necessary, then adds them to the DOM and positions them on screen.
+
+</p>
+<pre><code>new MM.Layer(provider [, parent])</code></pre>
+<p>Create a new map layer that uses a <strong>provider</strong>, optionally specifying a custom <strong>parent</strong> element (or container). A layer's <strong>provider</strong> is an instance of the <a href="#MapProvider">MapProvider</a> class, which converts <a href="#Coordinate">tile coordinates</a> into image URLs. This example provides <a href="http://placehold.it/">Placehold.it</a> URLs that list the tile coordinates:
+
+</p>
+<pre><code>var provider = new MM.MapProvider(function(coord) {
+    return "http://placehold.it/256x256&text=" +
+        [coord.zoom, coord.column, coord.row].join("/");
+});
+var layer = new MM.Layer(provider);
+map.addLayer(layer);</code></pre>
+<p>The <a href="#Template">Template</a> class simplifies generating image URLs for tile servers with popular template formats.
+
+</p>
+<p><a name="Layer.getProvider"></a>
+</p>
+<h3>getProvider <code>layer.getProvider()</code></h3>
+<p>Get the layer's current provider.
+
+</p>
+<p><a name="Layer.setProvider"></a>
+</p>
+<h3>setProvider <code>layer.setProvider()</code></h3>
+<p>Set the layer's current provider.
+
+</p>
+<p><a name="Layer.destroy"></a>
+</p>
+<h3>destroy <code>layer.destroy()</code></h3>
+<p>Destroy the layer, removing all of its tiles from memory and removing its <strong>parent</strong> element from the map.
+
+</p>
+<p><a name="Layer.draw"></a>
+</p>
+<h3>draw <code>layer.draw()</code></h3>
+<p>Redraw the layer by loading, unloading, adding, removing, and repositioning tile images as appropriate. Changing the provider triggers a <strong>draw</strong>.
+
+</p>
+<p><a name="Layer.requestRedraw"></a>
+</p>
+<h3>requestRedraw <code>layer.requestRedraw()</code></h3>
+<p>Request a layer redraw in 1 second. This works just like <a href="#Map.redraw">Map.redraw</a>.
+
+
+</p>
+<p><a name="MapProvider"></a>
+</p>
+<h2>MM.MapProvider</h2>
+<p>Map providers convert <a href="#Coordinate">tile coordinates</a> to image URLs. If your image tiles come in either <a href="#TemplateProvider-XYZ">XYZ</a> or <a href="#TemplateProvider-Quadkey">quadkey</a> formats, you should use the <a href="#TemplateProvider">TemplateProvider</a> class.
+
+</p>
+<pre><code>new MM.MapProvider(getTileUrl)</code></pre>
+<p><strong>MapProvider</strong> is an abstract class, meaning that it is meant to be <a href="#MM.extend">extended</a>. The constructor takes a function as its only argument, which is expected to return an image URL (or <code>null</code>) for a given <a href="#Coordinate">tile coordinate</a>. This example emulates the behavior of <a href="#Template">Template</a> using a static URL template:
+
+</p>
+<pre><code>var provider = new MM.MapProvider(function(coord) {
+    return "http://tile.stamen.com/toner/{Z}/{X}/{Y}.png"
+        .replace("{Z}", coord.zoom)
+        .replace("{X}", coord.column)
+        .replace("{Y}", coord.row);
+});
+// Coordinate(row, col, zoom)
+provider.getTile(new MM.Coordinate(1, 2, 3));
+// returns: "http://tile.stamen.com/toner/3/2/1.png"</code></pre>
+<p>Map providers expose the following interface to <a href="#Layer">Layer</a> objects:
+
+</p>
+<p><a name="MapProvider.getTile"></a>
+</p>
+<h3>getTile <code>provider.getTile(tileCoord)</code></h3>
+<p>Generates a tile URL or DOM element for the given <strong>tile coordinate</strong>. If the returned value is a string, an <code><img></code> element is created. Otherwise, if truthy, the return value is assumed to be a DOM element.
+
+</p>
+<p>For instance, you could create a map provider that generates <code><canvas></code> elements for each tile by customizing <strong>getTile</strong> like so (note that in this case, your tiles will need to either reside on the same server or be served with the appropriate <a href="http://enable-cors.org/">CORS headers</a>):
+
+</p>
+<pre><code>var myProvider = new MM.MapProvider(function(coord) {
+    return "path/to/tiles/" +
+        [coord.zoom, coord.column, coord.row].join("/") +
+        ".png";
+});
+myProvider.getTile = function(coord) {
+    var url = this.getTileUrl(coord);
+    if (url) {
+        var canvas = document.createElement("canvas");
+        canvas.width = canvas.height = 256;
+        var ctx = canvas.getContext("2d"),
+            img = new Image();
+        img.onload = function() {
+            canvas.drawImage(img);
+        };
+        img.src = url;
+        return canvas;
+    }
+};</code></pre>
+<p>NOTE: Because layers cache elements returned by this function, there is no guarantee that <strong>getTile</strong> will be called subsequently after a call to <strong>releaseTile</strong> with the same tile coordinate. If your provider needs to be notified of "re-added" tiles (ones that are generated once, released, then added again from the cache), it should implement <a href="#MapProvider.reAddTile">reAddTile</a>.
+
+</p>
+<p><a name="MapProvider.getTileUrl"></a>
+</p>
+<h3>getTileUrl <code>provider.getTileUrl(tileCoord)</code></h3>
+<p>Get the URL of the tile with the provided <strong>coordinate</strong>. In the abstract <strong>MapProvider</strong> class, <strong>getTile</strong> and <strong>getTileUrl</strong>
+
+</p>
+<p><a name="MapProvider.releaseTile"></a>
+</p>
+<h3>releaseTile <code>provider.releaseTile(tileCoord)</code></h3>
+<p>Clean up any resources required to display the <strong>tile coordinate's</strong> corresponding tile image or element. This is probably only necessary if your provider maintains references (such as a list or numeric reference count) to tiles generated by <strong>getTile</strong>.
+
+</p>
+<p><a name="MapProvider.reAddTile"></a>
+</p>
+<h3>reAddTile <code>provider.reAddTile(tileCoord)</code></h3>
+<p>If a provider implements the <strong>reAddTile</strong> method, cached tiles will be passed to this function so that the provider can know about the re-addition of tiles revived from the layer cache.
+
+
+</p>
+<p><a name="Template"></a>
+</p>
+<h2>MM.Template</h2>
+<p>ModestMap's Template class extends <a href="#MapProvider">MapProvider</a>, and converts <a href="#Coordinate">tile coordinates</a> to image URLs using a standard template format. These are the same constructor arguments as in <a href="#TemplatedLayer">TemplatedLayer</a>:
+
+</p>
+<pre><code>new MM.Template(urlTemplate [, subdomains])</code></pre>
+<p>Create a new templated provider based on the specified <strong>URL template</strong>, and an optional array of <strong>subdomain</strong> replacements. URL templates may contain the following placeholders:
+
+</p>
+<p><a name="Template.XYZ"></a>
+</p>
+<h3>X, Y, Z <code>http://example.com/tiles/{Z}/{X}/{Y}.ext</code></h3>
+<p>In an <strong>XYZ</strong> template, the <code>{X}</code>, <code>{Y}</code> and <code>{Z}</code> placeholders are replaced with each <a href="#Coordinate">tile's</a> <code>column</code>, <code>row</code> and <code>zoom</code> properties, respectively.
+
+</p>
+<pre><code>var toner = new MM.Template("http://tile.stamen.com/toner/{Z}/{X}/{Y}.png");</code></pre>
+<p><a name="Template.quadkey"></a>
+</p>
+<h3>Quadkey <code>http://example.com/tiles/{Q}.ext</code></h3>
+<p>In a <strong>quadkey</strong> template, the <code>{Q}</code> placeholder is replaced with each <a href="#Coordinate">tile's</a> <a href="http://msdn.microsoft.com/en-us/library/bb259689.aspx">quadkey string</a>. These are found on Microsoft's <a href="http://www.bing.com/maps/">Bing Maps</a> (previously VirtualEarth) tile servers:
+
+</p>
+<pre><code>var bingBase = "http://ecn.t0.tiles.virtualearth.net/tiles/r{Q}?";
+var bing = new MM.Template(bingBase + "g=689&mkt=en-us&lbl=l1&stl=h");</code></pre>
+<p><a name="Template.subdomains"></a>
+</p>
+<h3>Subdomains <code>http://{S}.example.com/...</code></h3>
+<p>If an array of <strong>subdomains</strong> is passed to the Template constructor, tile URLs will substitute a predictable selection from the array for any <code>{S}</code> placeholder (e.g., the first one gets <code>subdomains[0]</code>, the second gets <code>subdomains[1]</code>, etc.). Many tile servers support loading via multiple subdomains, e.g.:
+
+</p>
+<pre><code>var osm = new MM.Template("http://{S}.tile.openstreetmap.org/{Z}/{X}/{Y}.png",
+    ["a", "b", "c", "d"]);
+var bing = new MM.Template("http://ecn.t{S}.tiles.virtualearth.net/tiles/r{Q}" +
+    "?g=689&mkt=en-us&lbl=l1&stl=h",
+    [1, 2, 3, 4]);
+var terrain = new MM.Template("http://{S}.tile.stamen.com/terrain/{Z}/{X}/{Y}.png",
+    "a b c d".split(" "));</code></pre>
+<p><strong>Multiple subdomains may drastically speed up your maps!</strong> Most browsers place limits on the number of URLs that can be loaded simultaneously from each domain. Using two subdomains in effect doubles the number of image tiles that can load at the same time.
+
+</p>
+<p>NOTE: <code>{S}</code> placeholders need not <em>necessarily</em> refer to subdomains. You could, for instance, vary the entire hostname of each tile, like so:
+
+</p>
+<pre><code>var template = new MM.TemplateProvider("http://{S}/tiles/{Z}/{X}/{Y}.png",
+    ["example.com", "example.org", "example.net"]);</code></pre>
+<h2>Package Utilities</h2>
+<p>These are provided as useful shortcuts, often used to provide cross-browser compatibility.
+
+</p>
+<h3>MM.extend <code>MM.extend(childClass, parentClass)</code></h3>
+<p>Extend the <code>prototype</code> of <strong>child class</strong> with previously unspecified methods from the <strong>parent class</strong>'s <code>prototype</code>. This is how you extend classes in ModestMaps:
+
+</p>
+<pre><code>var MyLayer = function(provider) {
+    // do something MyLayer-specific
+    // then call the Layer constructor
+    MM.Layer.call(this, provider);
+};
+
+MyLayer.prototype = {
+    getTile: function(coord) {
+        // do something cool here
+    }
+};
+
+MM.extend(MyLayer, MM.Layer);</code></pre>
+<h3>MM.coerceLayer <code>MM.coerceLayer(layerish)</code></h3>
+<p>Coerce the provided <strong>layerish</strong> string or object into a <a href="#Layer">Layer</a>, according to the following rules:
+
+</p>
+<ol>
+<li>If <strong>layerish</strong> is a string, return a new <a href="#TemplatedLayer">TemplatedLayer</a> with <strong>layerish</strong> as the URL template.</li>
+<li>If <strong>layerish</strong> has a <code>draw</code> function, assume that it's a <a href="#Layer">Layer</a> instance and return it.</li>
+<li>Otherwise, assume that it's a <a href="#MapProvider">MapProvider</a> and return a new <a href="#Layer">Layer</a> with it as the constructor argument: <code>new MM.Layer(layerish)</code>.</li>
+</ol>
+<h3>MM.addEvent <code>MM.addEvent(element, eventType, listener)</code></h3>
+<p>Adds the <strong>listener</strong> to the provided <strong>DOM element</strong> for the given <strong>event type</strong>. In browsers that support <a href="http://www.w3.org/TR/DOM-Level-2-Events/">DOM Level 2 events</a>, this calls <code>element.addEventListener(eventType, listener, false)</code>. In older versions of Internet Explorer, this uses <code>element.attachEvent()</code>.
+
+</p>
+<pre><code>var link = document.getElementById("null-island"),
+    nullIsland = new MM.Location(0, 0);
+MM.addEvent(link, "click", function(e) {
+    map.setCenterZoom(nullIsland, 12);
+    return MM.cancelEvent(e);
+});</code></pre>
+<p>You can remove event listeners with <a href="#MM.removeEvent">MM.removeEvent</a>.
+
+</p>
+<h3>MM.removeEvent <code>MM.removeEvent(element, eventType, listener)</code></h3>
+<p>Removes the <strong>listener</strong> from <strong>element</strong> for the given <strong>event type</strong>.
+
+</p>
+<pre><code>MM.removeEvent(link, "click", onClick);</code></pre>
+<h3>MM.cancelEvent <code>MM.cancelEvent(event)</code></h3>
+<p>Does whatever is necessary to cancel the provided DOM event and returns <code>false</code>. This is useful for preventing the default behavior or <code>click</code> events, e.g.:
+
+</p>
+<pre><code>var zoomIn = document.getElementById("zoom-in");
+MM.addEvent(zoomIn, "click", function(e) {
+    map.zoomIn();
+    return MM.cancelEvent(e);
+});</code></pre>
+<h3>MM.getStyle <code>MM.getStyle(element, property)</code></h3>
+<p>Get the <strong>element</strong>'s <a href="https://developer.mozilla.org/en/DOM/window.getComputedStyle">computed style</a> of the named <strong>CSS property</strong>.
+
+</p>
+<pre><code>var bgcolor = MM.getStyle(map.parent, "background-color");</code></pre>
+<h3>MM.moveElement <code>MM.moveElement(element, point)</code></h3>
+<p>Updates the CSS properties of <strong>element</strong> so that it appears at the absolute position <strong>point</strong>. If available, this function uses <a href="http://www.w3.org/TR/css3-transforms/">CSS transforms</a> (which are often hardware accelerated, and thus faster than traditional <code>top</code> and <code>left</code> properties).
+
+
+</p>
+<pre><code>var marker = document.getElementById("marker"),
+    sf = new MM.Location(37.764, -122.419);
+map.addCallback("drawn", function() {
+    var point = map.locationPoint(sf);
+    MM.moveElement(marker, point);
+});</code></pre>
+<p>(See the section on <a href="#Coordinate-pre-projecting">pre-projecting</a> for a slightly better way of doing this.)
+
+</p>
+<h3>MM.getFrame <code>MM.getFrame(frameCallback)</code></h3>
+<p>This is a stand-in for <a href="https://developer.mozilla.org/en/DOM/window.requestAnimationFrame">requestAnimationFrame</a>, a feature of modern browsers that calls the <strong>frame callback</strong> function as often as possible without affecting page repainting.
+
+</p>
+<h3>MM.transformProperty <code>MM.transformProperty</code></h3>
+<p>The name of the property used by the running browser to provide <a href="http://www.w3.org/TR/css3-transforms/">CSS transforms</a>.
+
+</p>
+<h3>MM.matrixString <code>MM.matrixString(point)</code></h3>
+<p>Convert <strong>point</strong> into a CSS transform-compatible matrix string.
+
+</p>
+
+        </div>
+    </body>
+</html>
diff --git a/doc/middle.html b/doc/middle.html
new file mode 100644
index 0000000..b88d651
--- /dev/null
+++ b/doc/middle.html
@@ -0,0 +1,3 @@
+        </div>
+
+        <div id="content" class="container">
diff --git a/doc/start.html b/doc/start.html
new file mode 100644
index 0000000..ef9298f
--- /dev/null
+++ b/doc/start.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>modestmaps.js v{VERSION}</title>
+        <style type="text/css">
+            @import url(css/main.css);
+        </style>
+    </head>
+    <body>
+        <div id="toc">
+            <h1>modestmaps.js</h1>
+            <p class="version"><code>v{VERSION}</code></p>
diff --git a/doc/toc.md b/doc/toc.md
new file mode 100644
index 0000000..7845792
--- /dev/null
+++ b/doc/toc.md
@@ -0,0 +1,108 @@
+## [Getting the Source](#source)
+## [Quick Start](#quick-start)
+* [Making a map](#quick.map)
+* [Moving around](#quick.moving)
+* [Working with layers](#quick.layers)
+
+## [Map](#Map)
+* [getCenter](#Map.getCenter)
+* [setCenter](#Map.setCenter)
+* [getZoom](#Map.getZoom)
+* [setZoom](#Map.setZoom)
+* [setCenterZoom](#Map.setCenterZoom)
+* [getExtent](#Map.getExtent)
+* [setExtent](#Map.setExtent)
+* [zoomIn](#Map.zoomIn)
+* [zoomOut](#Map.zoomOut)
+* [zoomBy](#Map.zoomBy)
+* [zoomByAbout](#Map.zoomByAbout)
+* [panBy](#Map.panBy)
+* [panLeft](#Map.panLeft)
+* [panRight](#Map.panRight)
+* [panUp](#Map.panUp)
+* [panDown](#Map.panDown)
+* [center](#Map.center)
+* [zoom](#Map.zoom)
+* [extent](#Map.extent)
+* [addLayer](#Map.addLayer)
+* [removeLayer](#Map.removeLayer)
+* [getLayers](#Map.getLayers)
+* [getLayerAt](#Map.getLayerAt)
+* [setLayerAt](#Map.setLayerAt)
+* [insertLayerAt](#Map.insertLayerAt)
+* [removeLayerAt](#Map.removeLayerAt)
+* [swapLayersAt](#Map.swapLayersAt)
+* [addCallback](#Map.addCallback)
+* [removeCallback](#Map.removeCallback)
+* [pointLocation](#Map.pointLocation)
+* [pointCoordinate](#Map.pointCoordinate)
+* [locationPoint](#Map.locationPoint)
+* [locationCoordinate](#Map.locationCoordinate)
+* [coordinateLocation](#Map.coordinateLocation)
+* [coordinatePoint](#Map.coordinatePoint)
+* [setZoomRange](#Map.setZoomRange)
+* [setSize](#Map.setSize)
+* [autoSize](#Map.autoSize)
+* [dimensions](#Map.dimensions)
+* [draw](#Map.draw)
+* [requestRedraw](#Map.requestRedraw)
+* [parent](#Map.parent)
+* [coordinate](#Map.coordinate)
+* [coordLimits](#Map.coordLimits)
+* [tileSize](#Map.tileSize)
+
+## [Location](#Location)
+* [latitude](#Location.lat) and [longitude](#Location.lon)
+* [Location.fromString](#Location.fromString)
+* [Location.distance](#Location.fromString)
+* [Location.interpolate](#Location.fromString)
+* [Location.bearing](#Location.fromString)
+
+## [Extent](#Extent)
+* [north](#Extent.north), [east](#Extent.east), [south](#Extent.south) and [west](#Extent.west)
+* [northWest](#Extent.northWest)
+* [northEast](#Extent.northEast)
+* [southEast](#Extent.southEast)
+* [southWest](#Extent.southWest)
+* [containsLocation](#Extent.containsLocation)
+* [encloseLocation](#Extent.encloseLocation)
+* [encloseLocations](#Extent.encloseLocations)
+* [encloseExtent](#Extent.encloseExtent)
+* [setFromLocations](#Extent.setFromLocations)
+* [copy](#Extent.copy)
+* [toArray](#Extent.toArray)
+* [Extent.fromString](#Extent.fromString)
+* [Extent.fromArray](#Extent.fromArray)
+
+## [Point](#Point)
+* [Point.distance](#Point.distance)
+* [Point.interpolate](#Point.interpolate)
+
+## [Coordinate](#Coordinate)
+* [zoom](#Coordinate.zoom), [column](#Coordinate.column) and [row](#Coordinate.row)
+* [zoomTo](#Coordinate.zoomTo)
+* [zoomBy](#Coordinate.zoomBy)
+* [container](#Coordinate.container)
+* [up](#Coordinate.up)
+* [down](#Coordinate.down)
+* [left](#Coordinate.left)
+* [right](#Coordinate.right)
+* [toKey](#Coordinate.toKey)
+* [toString](#Coordinate.toString)
+
+## [TemplatedLayer](#TemplatedLayer)
+
+## [Layer](#Layer)
+* [getProvider](#Layer.getProvider)
+* [setProvider](#Layer.setProvider)
+* [draw](#Layer.draw)
+* [requestRedraw](#Layer.requestRedraw)
+
+## [Template](#Template)
+
+## [MapProvider](#MapProvider)
+* [getTile](#MapProvider.getTile)
+* [getTileUrl](#MapProvider.getTileUrl)
+* [releaseTile](#MapProvider.releaseTile)
+* [reAddTile](#MapProvider.reAddTile)
+
diff --git a/examples/geojson/modestmaps.markers.js b/examples/geojson/modestmaps.markers.js
index 4dc8e55..42c2f5d 100644
--- a/examples/geojson/modestmaps.markers.js
+++ b/examples/geojson/modestmaps.markers.js
@@ -187,7 +187,7 @@ if (!com.modestmaps) {
                 // offset by the layer parent position if x or y is non-zero
                 if (this.position.x || this.position.y) {
                     pos.x -= this.position.x;
-                    pox.y -= this.position.y;
+                    pos.y -= this.position.y;
                 }
                 marker.style.left = ~~(pos.x + .5) + "px";
                 marker.style.top = ~~(pos.y + .5) + "px";
diff --git a/examples/node/modestmaps-static.js b/examples/node/modestmaps-static.js
index 8ab5752..df5fffa 100644
--- a/examples/node/modestmaps-static.js
+++ b/examples/node/modestmaps-static.js
@@ -15,7 +15,7 @@ function renderStaticMap(provider, dimensions, zoom, location, callback) {
                                  Math.PI,  Math.PI, 1, 0,
                                 -Math.PI, -Math.PI, 0, 1)),
       tileSize = new MM.Point(256, 256);
-  
+
   var centerCoordinate = projection.locationCoordinate(location).zoomTo(zoom);
 
   function pointCoordinate(point) {
@@ -24,7 +24,7 @@ function renderStaticMap(provider, dimensions, zoom, location, callback) {
     coord.column += (point.x - dimensions.x/2) / tileSize.x;
     coord.row += (point.y - dimensions.y/2) / tileSize.y;
     return coord;
-  };
+  }
 
   function coordinatePoint(coord) {
     // Return an x, y point on the map image for a given coordinate.
@@ -38,7 +38,7 @@ function renderStaticMap(provider, dimensions, zoom, location, callback) {
   }
 
   var startCoord = pointCoordinate(new MM.Point(0,0)).container(),
-      endCoord = pointCoordinate(dimensions).container(); 
+      endCoord = pointCoordinate(dimensions).container();
 
   var numRequests = 0,
       completeRequests = 0;
@@ -50,7 +50,7 @@ function renderStaticMap(provider, dimensions, zoom, location, callback) {
   }
 
   function getTile(url, p) {
-    new get(url).asBuffer(function(error,data) { 
+    new get(url).asBuffer(function(error,data) {
       if (error) {
         callback(url + ' error: ' + error);
       }
@@ -75,34 +75,12 @@ function renderStaticMap(provider, dimensions, zoom, location, callback) {
       }
     }
   }
-  
 }
 
-/* 
-var provider = new MM.TemplatedMapProvider("http://tile.openstreetmap.org/{Z}/{X}/{Y}.png");
-var dimensions = new MM.Point(800, 600);
-var zoom = 11;
-var location = new MM.Location(37.774929, -122.419415);
-
-renderStaticMap(provider, dimensions, 11, location, function(err, canvas) {
-  if (err) {
-    throw err;
-  }
-  var out = fs.createWriteStream(__dirname + '/map.png'),
-      stream = canvas.createPNGStream();
-  stream.on('data', function(chunk){
-    out.write(chunk);
-  });
-  stream.on('end', function(){
-    console.log('saved map.png');
-  });
-});
-*/
-
 // just one for now...
 var providers = {
-  osm: new MM.TemplatedLayer("http://tile.openstreetmap.org/{Z}/{X}/{Y}.png")
-}
+  osm: new MM.Template("http://tile.openstreetmap.org/{Z}/{X}/{Y}.png")
+};
 
 var app = express.createServer();
 
@@ -111,12 +89,12 @@ app.get('/map', function(req,res) {
       width = req.param("width", 800),
       height = req.param("height", 600),
       dimensions = new MM.Point(width, height),
-      zoom = parseInt(req.param("zoom", 1)),
+      zoom = parseInt(req.param("zoom", 1), 10),
       lat = req.param("lat", 0.0),
       lon = req.param("lon", 0.0),
       location = new MM.Location(lat, lon);
   renderStaticMap(provider, dimensions, zoom, location, function(err,canvas) {
-    if (err) {    
+    if (err) {
       res.send(new Error(err));
     } else {
       res.header('Content-Type', 'image/png');
@@ -126,6 +104,3 @@ app.get('/map', function(req,res) {
 });
 
 app.listen(3000);
-
-
-
diff --git a/examples/spotlight/modestmaps.markers.js b/examples/spotlight/modestmaps.markers.js
index 4dc8e55..42c2f5d 100644
--- a/examples/spotlight/modestmaps.markers.js
+++ b/examples/spotlight/modestmaps.markers.js
@@ -187,7 +187,7 @@ if (!com.modestmaps) {
                 // offset by the layer parent position if x or y is non-zero
                 if (this.position.x || this.position.y) {
                     pos.x -= this.position.x;
-                    pox.y -= this.position.y;
+                    pos.y -= this.position.y;
                 }
                 marker.style.left = ~~(pos.x + .5) + "px";
                 marker.style.top = ~~(pos.y + .5) + "px";
diff --git a/modestmaps.js b/modestmaps.js
index 3e8638e..71faf87 100644
--- a/modestmaps.js
+++ b/modestmaps.js
@@ -1,5 +1,5 @@
 /*!
- * Modest Maps JS v3.3.4
+ * Modest Maps JS v3.3.6
  * http://modestmaps.com/
  *
  * Copyright (c) 2011 Stamen Design, All Rights Reserved.
@@ -749,10 +749,12 @@ var MM = com.modestmaps = {
         // return null if wrapped coordinate is outside of the tile limits
         sourceCoordinate: function(coord) {
             var TL = this.tileLimits[0].zoomTo(coord.zoom).container(),
-                BR = this.tileLimits[1].zoomTo(coord.zoom).container().right().down(),
+                BR = this.tileLimits[1].zoomTo(coord.zoom),
                 columnSize = Math.pow(2, coord.zoom),
                 wrappedColumn;
 
+            BR = new MM.Coordinate(Math.ceil(BR.row), Math.ceil(BR.column), Math.floor(BR.zoom));
+
             if (coord.column < 0) {
                 wrappedColumn = ((coord.column % columnSize) + columnSize) % columnSize;
             } else {
@@ -1970,6 +1972,7 @@ var MM = com.modestmaps = {
             this.enabled = true;
             this.parent.style.display = '';
             this.draw();
+            return this;
         },
 
         // Disable a layer, don't display in DOM, clear all requests
@@ -1977,6 +1980,7 @@ var MM = com.modestmaps = {
             this.enabled = false;
             this.requestManager.clear();
             this.parent.style.display = 'none';
+            return this;
         },
 
         // Remove this layer from the DOM, cancel all of its requests
@@ -2213,6 +2217,7 @@ var MM = com.modestmaps = {
 
         setCenterZoom: function(location, zoom) {
             this.coordinate = this.projection.locationCoordinate(location).zoomTo(parseFloat(zoom) || 0);
+            this.coordinate = this.enforceLimits(this.coordinate);
             MM.getFrame(this.getRedraw());
             this.dispatchCallback('centered', [location, zoom]);
             return this;
@@ -2278,8 +2283,8 @@ var MM = com.modestmaps = {
 
         setExtent: function(locations, precise) {
             this.coordinate = this.extentCoordinate(locations, precise);
-            this.draw(); // draw calls enforceLimits
-            // (if you switch to getFrame, call enforceLimits first)
+            this.coordinate = this.enforceLimits(this.coordinate);
+            MM.getFrame(this.getRedraw());
 
             this.dispatchCallback('extentset', locations);
             return this;
diff --git a/modestmaps.min.js b/modestmaps.min.js
index 14bfa81..44df7b3 100644
--- a/modestmaps.min.js
+++ b/modestmaps.min.js
@@ -1,5 +1,5 @@
-/*
- * Modest Maps JS v3.3.4
+/*!
+ * Modest Maps JS v3.3.6
  * http://modestmaps.com/
  *
  * Copyright (c) 2011 Stamen Design, All Rights Reserved.
@@ -10,5 +10,5 @@
  * Versioned using Semantic Versioning (v.major.minor.patch)
  * See CHANGELOG and http://semver.org/ for more details.
  *
- */
-var previousMM=MM;if(!com){var com={};if(!com.modestmaps){com.modestmaps={}}}var MM=com.modestmaps={noConflict:function(){MM=previousMM;return this}};(function(a){a.extend=function(d,b){for(var c in b.prototype){if(typeof d.prototype[c]=="undefined"){d.prototype[c]=b.prototype[c]}}return d};a.getFrame=function(){return function(b){(window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFra [...]
\ No newline at end of file
+ */var previousMM=MM;if(!com){var com={};com.modestmaps||(com.modestmaps={})}var MM=com.modestmaps={noConflict:function(){return MM=previousMM,this}};(function(a){a.extend=function(a,b){for(var c in b.prototype)typeof a.prototype[c]=="undefined"&&(a.prototype[c]=b.prototype[c]);return a},a.getFrame=function(){return function(a){(window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame| [...]
+this.layers[a],d=this.layers[b],e=document.createElement("div");return this.parent.replaceChild(e,d.parent),this.parent.replaceChild(d.parent,c.parent),this.parent.replaceChild(c.parent,e),this.layers[a]=d,this.layers[b]=c,this},enableLayer:function(a){var b=this.getLayer(a);return b&&b.enable(),this},enableLayerAt:function(a){var b=this.getLayerAt(a);return b&&b.enable(),this},disableLayer:function(a){var b=this.getLayer(a);return b&&b.disable(),this},disableLayerAt:function(a){var b=th [...]
\ No newline at end of file
diff --git a/package.json b/package.json
index 022b0bc..4733d53 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
 {
   "name": "modestmaps",
   "description": "a display and interaction library for tile-based maps",
-  "version": "3.3.4",
+  "version": "3.3.6",
   "author": {
     "name": "Tom Carden",
     "email": "tom at tom-carden.co.uk",
diff --git a/src/layer.js b/src/layer.js
index adf33cf..89a7713 100644
--- a/src/layer.js
+++ b/src/layer.js
@@ -406,6 +406,7 @@
             this.enabled = true;
             this.parent.style.display = '';
             this.draw();
+            return this;
         },
 
         // Disable a layer, don't display in DOM, clear all requests
@@ -413,6 +414,7 @@
             this.enabled = false;
             this.requestManager.clear();
             this.parent.style.display = 'none';
+            return this;
         },
 
         // Remove this layer from the DOM, cancel all of its requests
diff --git a/src/map.js b/src/map.js
index b85d1a7..6e707d8 100644
--- a/src/map.js
+++ b/src/map.js
@@ -217,6 +217,7 @@
 
         setCenterZoom: function(location, zoom) {
             this.coordinate = this.projection.locationCoordinate(location).zoomTo(parseFloat(zoom) || 0);
+            this.coordinate = this.enforceLimits(this.coordinate);
             MM.getFrame(this.getRedraw());
             this.dispatchCallback('centered', [location, zoom]);
             return this;
@@ -282,8 +283,8 @@
 
         setExtent: function(locations, precise) {
             this.coordinate = this.extentCoordinate(locations, precise);
-            this.draw(); // draw calls enforceLimits
-            // (if you switch to getFrame, call enforceLimits first)
+            this.coordinate = this.enforceLimits(this.coordinate);
+            MM.getFrame(this.getRedraw());
 
             this.dispatchCallback('extentset', locations);
             return this;
diff --git a/src/provider.js b/src/provider.js
index b6148ec..8e4a7d7 100644
--- a/src/provider.js
+++ b/src/provider.js
@@ -43,10 +43,12 @@
         // return null if wrapped coordinate is outside of the tile limits
         sourceCoordinate: function(coord) {
             var TL = this.tileLimits[0].zoomTo(coord.zoom).container(),
-                BR = this.tileLimits[1].zoomTo(coord.zoom).container().right().down(),
+                BR = this.tileLimits[1].zoomTo(coord.zoom),
                 columnSize = Math.pow(2, coord.zoom),
                 wrappedColumn;
 
+            BR = new MM.Coordinate(Math.ceil(BR.row), Math.ceil(BR.column), Math.floor(BR.zoom));
+
             if (coord.column < 0) {
                 wrappedColumn = ((coord.column % columnSize) + columnSize) % columnSize;
             } else {
diff --git a/src/start.js b/src/start.js
index fb0a31c..79064ad 100644
--- a/src/start.js
+++ b/src/start.js
@@ -1,5 +1,5 @@
 /*!
- * Modest Maps JS v3.3.4
+ * Modest Maps JS v{VERSION}
  * http://modestmaps.com/
  *
  * Copyright (c) 2011 Stamen Design, All Rights Reserved.
diff --git a/test/spec/Map.js b/test/spec/Map.js
index fca15c8..ee2a9a7 100644
--- a/test/spec/Map.js
+++ b/test/spec/Map.js
@@ -56,6 +56,13 @@ describe('Map', function() {
       expect(typeof map.coordinate.zoom).toEqual('number');
   });
 
+  it('enforces limits when setting an extent', function() {
+      map.dimensions = { x: 800, y: 800 };
+      map.zoom(2).center({ lat: 54.5259614, lon:15.2551187 });
+      expect(map.locationPoint({ lat: 40.7143528, lon: -74.0059731 }).y)
+        .toBeCloseTo(384.9985102776103);
+  });
+
   describe('Navigation', function() {
       it('binds and calls drawn', function() {
           spyOn(sink, 'receive');

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/modestmaps-js.git



More information about the Pkg-javascript-commits mailing list