topoJson

A layer that contains TopoJSON features. Extends geoJson, layer, dispatch.

mapsense.topoJson([f])

Constructs a new TopoJSON layer with default settings.

An optional fetch function f may be specified, which defaults to mapsense.queue.json. The fetch function takes two arguments: the URL to fetch as a string, and a callback function. The fetch function must return a request object with an abort method. The callback function should be invoked with the TopoJSON data when available.

The fetch function may be substituted to support TopoJSON transcoding.

topoJson.staticTopology([x])

Sets or gets the “hard-coded” topology for this TopoJSON layer. If the argument x is specified, this method sets the topology to the given TopoJSON topology and returns this. If no arguments are specified, this method returns the current topology, which defaults to null.

The purpose of this method is to support non-tiled TopoJSON layers that are loaded through external means, such as via JSONP or directly embedded in the HTML. Specifying the topology has the additional side-effect of disabling tiling and clipping.

topoJson.topologyFeatures([x])

Sets or gets the function used for converting a TopoJSON topology to GeoJSON features. If the argument x is specified, this method sets the conversion function and returns this. If no arguments are specified, this method returns the current conversion function.

topoJson.classify([x])

Sets or gets the function used for classifying features. The function is invoked once for each feature, and its return value is used to determine equivalence classes for grouping. Features whose classification value are identical are grouped together into a geometry collection. The order of features in the original topology is preserved for features within a geometry collection.