Class deCarta.Mobile.Polyline
Polyline is a map overlay object used to draw a complex line (such as a route) on the map. It extends deCarta.Mobile.OverlayObject. Use the deCarta.Mobile.MapOverlay:addObject() method to add this object to a map overlay. (for example a route).
POINT INDEXES AND THINNING
When a line is rendered, all the points are indexed by the tile they fall on to, given the zoom level. On zoom level changes, a new index is built.
Creating the index is a linear operation, we look at each point and assign it to a tile key. The index structure is an object with properties named as tile keys which contain an array of indexes referring to the list of positions that make up the polyline.
For example :
var index = [
10: {
'10_-347_113' : [0, 34]
}
]
NOTE: the indexes refer to the genGeom array, which contains (by zoom lev) the generalized geometry (contiguous points). These indexes contain indexes into the real geometry.
This means we have an index built for level 10, and tile 10, -347, 133 contains points 0 and 34 of our positions array.
Points in the index have already undergone thinning (in fact it is part of the same linear operation that builds the index) so they can simply be taken and drawn on screen.| Constructor Attributes | Constructor Name and Description |
|---|---|
|
deCarta.Mobile.Polyline(opts)
An OverlayObject used to display a polyline on a MapOverlay
|
| Method Attributes | Method Name and Description |
|---|---|
|
Returns the best center (Position) and Zoom (int) to display this polyline
|
|
|
Overrides the standard deCarta.Mobile.OverlayObject:getPosition() method
|
|
|
getSize(z)
Returns size of the polyline's bounding box at a given zoom level
|
- Parameters:
- {object} opts
- Options. May contain one or more of the following
- lineGeometry: Array of point geometry in string format - required
- fillColor: A polyline has thickness, and therefore has a fill color - optional, default '#000'
- strokeColor: Color hat will be used to stroke the line - optional, default '#0000FF'
- strokeSize: Size of the line, in pixels - optional, default 6
- strokeOpacity: Opacity of the line (1.0 = opaque, 0.0 = transparent) - optional, default 0.6
- Parameters:
- {deCarta.Mobile.Map} map
- The current map view
- Returns:
- {zoom|center} Ideal zoom level (1 to 20), and center position deCarta.Mobile.Position
- Returns:
- {deCarta.Mobile.Position} Returns the top left geographic position of the polyline's bounding rectangle
- Parameters:
- {int} z
- zoom level (20=maxzoom, 1=minzoom)
- Returns:
- {width|height} Size of the geographic bounding box of the polyline