new GeolocationDraw(options)
Parameters:
Name | Type | Description |
---|---|---|
options |
any | |
option.features |
ol.Collection.<ol.Feature> | undefined | Destination collection for the drawn features. |
options.source |
ol.source.Vector | undefined | Destination source for the drawn features. |
options.type |
ol.geom.GeometryType | Drawing type ('Point', 'LineString', 'Polygon'), default LineString. |
options.minAccuracy |
Number | undefined | minimum accuracy underneath a new point will be register (if no condition), default 20 |
options.condition |
function | undefined | a function that take a ol.Geolocation object and return a boolean to indicate whether location should be handled or not, default return true if accuracy < minAccuracy |
options.attributes |
Object | a list of attributes to register as Point properties: {accuracy:true,accuracyGeometry:true,heading:true,speed:true}, default none. |
options.tolerance |
Number | tolerance to add a new point (in meter), default 5 |
options.zoom |
Number | zoom for tracking, default 16 |
options.minZoom |
Number | min zoom for tracking, if zoom is less it will zoom to it, default use zoom option |
options.followTrack |
boolean | auto | position | visible | true if you want the interaction to follow the track on the map, default true |
options.style |
ol.style.Style | Array.<ol.style.Style> | ol.StyleFunction | undefined | Style for sketch features. |
Fires:
- drawstart, drawend, drawing, tracking,event: follow
Extends
- ol.interaction.Interaction
Methods
-
getPosition(loc)
-
Get a position according to the geolocation
Parameters:
Name Type Description loc
Geolocation Returns:
an array of measure X,Y,Z,T
- Type
- Array.<any>
-
isPaused()
-
Is paused
Returns:
b
- Type
- boolean
-
pause(b)
-
Pause drawing
Parameters:
Name Type Description b
boolean -
reset()
-
Reset drawing
-
setActive(active)
-
Activate or deactivate the interaction.
Parameters:
Name Type Description active
boolean -
setFollowTrack(follow,)
-
Enable following the track on the map
Parameters:
Name Type Description follow,
boolean | auto | position | visible false: don't follow, true: follow (position+zoom), 'position': follow only position, 'auto': start following until user move the map, 'visible': center when position gets out of the visible extent
-
setMap(map)
-
Remove the interaction from its current map, if any, and attach it to a new map, if any. Pass
null
to just remove the interaction from the current map.Parameters:
Name Type Description map
ol.Map Map.
-
simplify3D(geo, tolerance)
-
Simplify 3D geometry
Parameters:
Name Type Description geo
ol.geom.Geometry tolerance
number -
simulate(track, options, delay, accuracy, repeat)
-
Simulate a track and override current geolocation
Parameters:
Name Type Description track
Array.<ol.coordinate> | boolean a list of point or false to stop
options
* delay
number delay in ms, default 1000 (1s)
accuracy
number gps accuracy, default 10
repeat
boolean repeat track, default true
-
simulating()
-
Is simulation on ?
Returns:
- Type
- boolean
-
start()
-
Start tracking = setActive(true)
-
stop()
-
Stop tracking = setActive(false)