-
Notifications
You must be signed in to change notification settings - Fork 67
Zoom Factors
The zoomFactors
array allows for fine-grained control over how the transitive renders the network relative the the current zoom level. zoomFactors is an array of one or more 'zoom factor' objects. If no zoomFactors
object is specified, the following defaults are used:
[{
minScale: 0,
gridCellSize: 25,
internalVertexFactor: 1000000,
angleConstraint: 45,
mergeVertexThreshold: 200
}, {
minScale: 1.5,
gridCellSize: 0,
internalVertexFactor: 0,
angleConstraint: 5,
mergeVertexThreshold: 0
}]
Multiple zoom factor objects can be provided to assign different rendering properties to different ranges of the zoom scale spectrum; i.e. you may want a more stylized map when zoomed out and a more geographically accurate map when zoomed in (which is the effect of the default settings above, explained further below).
Zoom level is expressed as a positive integer indicating the display scale factor relative to the initial display state. For example, 1.5 means that the user has zoomed in such that a segment that was 100px long when first rendered is now 150px long.
Each zoom factor object consists of the following properties:
-
minScale
: The zoom level that is the lower bound of the range for which this settings object has effect. There is no explicitly stated 'maxScale' factor; when multiple zoom factor objects are present the upper bound of a given item is assumed to be theminScale
of the following item in the zoomFactors array. (The last item in the the array has an implied upper bound of infinity.) -
gridCellSize
: The resolution of the grid that all vertices are snapped to. If set to 0, grid snapping is disabled. Specified in Mercator meters -
mergeVertexThreshold
: The tolerance used for merging nearby input data vertices to single rendered veritices. If set to 0, grid snapping is disabled. Specified in Mercator meters. -
internalVertexFactor
: The minimum interval at which internal vertices of a segment (i.e. purely shape-defining vertices that do not otherwise define the graph topology) are actually rendered as distinct points. A higher factor means fewer shape vertices and more stylized segments; a lower factor mean more frequent shape points and a more realistic map. Specified in Mercator meters. -
angleConstraint
: The angle increment, specified in degrees, to which all segment endpoints are 'snapped' during rendering. Higher values mean a more stylized map; lower mean more realistic. For best results, use values from the divisors of 90 degrees (5, 10, 30, 45, etc.)
To review the default example specified:
[{ // The first item defines the "styled" display
minScale: 0, // Take effect at scale factor 0 (i.e. zoomed out "all the way"')
gridCellSize: 25, // Snap to a grid of 25 meters square
internalVertexFactor: 1000000, // Effectively ignore all segment shape points (TODO: allow Infinity here?)
angleConstraint: 45, // Snap endpoint angles to 45 degrees, i.e. the classic 'subway map' look
mergeVertexThreshold: 200 // Merge vertices within 200m of each other
},
{ // The second item defines the "real-world" display that takes over when zoomed in closer
minScale: 1.5, // Take effect at scale 1.5, i.e. zoomed in 50% relative to the initial state or greater
gridCellSize: 0, // Don't snap to any grid
internalVertexFactor: 0, // Place all segment shape points, however frequent
angleConstraint: 5, // Apply very slight snapping to angles
mergeVertexThreshold: 0 // Don't merge vertices ever
}]