Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

MM.Coordinate

tmcw edited this page Feb 15, 2012 · 1 revision

Coordinate

Coordinates are places in tiles. They're geographic but in a way more specific than Location and not based on conventional latitude and longitude - they represent tile coordinates and include a z - zoom - dimension.

Constructor

var coord = new MM.Coordinate(row, column, zoom);

Instance Methods

// Get a string key to refer to this coordinate
var key = coord.toKey();

// Get the whole-number coordinate that contains a potentially
// in-between coordinate
var container = coord.container();

// Get a copy of this coordinate
var copy = coord.copy();

// Navigation with coordinates
var zoomedTo = coord.zoomTo(5);
var zoomedIn = coord.zoomTo(1);
var pannedLeft = coord.left(1);

Coordinate is used internally to represent tiles, and the map state - so they have instance functions that let you do all of the navigation that you'd expect out of a map. It has row, column and zoom properties.

It also has several methods that help you navigate from one coordinate to another: up, right, down, left, zoomTo and zoomBy. All return a new Coordinate. Additionally, copy can be used to clone a Coordinate and container can be used to obtain a Coordinate with floored row, column and zoom for generating tile URLs.

Clone this wiki locally