Overview Examples Documentation Download

hash

map

po.hash()

Constructs a hash control with default settings. The hash control provides two-way coordination of the window’s location hash with the map center and zoom. This allows map URLs to be conveniently copy-and-pasted, preserving the view. To further cut down on URL length, the precision of latitude and longitude is based on the zoom level.

The hash control also listens for the window “hashchange” event, such that links on the page or editing via the address bar can update the map center and zoom.

hash.map([x])

Adds this control to the specified map x, removes this control from its current map, or returns the current map. This method is typically not called directly, but is needed to support the map’s add method and remove methods.

If the argument x is specified, this method returns this. If x is null, this control is removed from its current map; otherwise, this control is added to the specified map. If no arguments are specified, this method returns the current map, which may be null. Whew!

hash.parser([x])

In combination with formatter, parser allows you to override the behavior of the polymaps permalink to include extra parameters. The supplied function x must accept two arguments: a map and a string representing the url fragment after the #. It should return true if the hash is invalid, otherwise it should apply the hash to the supplied map directly.

If the argument x is specified, this method returns this. If x is a function it will be used to apply url fragment changes to the map. If no arguments are specified, this method returns the current parser.

hash.formatter([x])

In combination with parser, formatter allows you to override the behavior of the polymaps permalink to include extra parameters. The supplied function x must accept a map as its only argument and return a string representing the map state preceded with a #. The format must be understood by the current parser.

If the argument x is specified, this method returns this. If x is a function it will be used to generate url fragment changes. If no arguments are specified, this method returns the current formatter.

Polymaps is a project from SimpleGeo and Stamen.