LineString selection tool
npm install leaflet-linestring-selectLineString selection tool: you can select a part or a stretch of a polyline on the map. Performance-oriented, uses rbush for segment lookup
Look how this thing deals with a coastline polyline consisting of ~500 points
| Option | type | default value |
| - | - | - |
| startMarkerClass | string | 'select-marker select-start-marker' |
| endMarkerClass | string | 'select-marker select-end-marker' |
| movingMarkerClass | string | 'select-marker select-moving-marker' |
| name | string | 'leaflet-linestring-select' |
| lineWeight | number | 4 |
| lineTolerance | number | L.Browser.mobile ? 10 : 5 |
| movingMarkerStyle | L.CircleMarcerOptions | { |
fillColor: '#fff',
fillOpacity: 1,
weight: 2,
opacity: 0.5,
color: '#000'
}
| endpointStyle | L.CircleMarcerOptions | { |
radius: 5,
color: '#111',
fillColor: '#fff',
fillOpacity: 1
}
| selectionStyle | L.PolylineOptions | {
color: '#0ff',
opacity: 1
} |
| useTouch | boolean | L.Browser.mobile |
| position | 'topright'|'topleft'|'bottomleft'|'bottomright' | 'topright' |
.enable({layer: polyline, feature: feature})
Enables control, initializes it with provided polyline. You can pass GeoJSON object as well, otherwise it will be auto-generated
.disable()
Disable control, remove handlers and selection
.reset()
Reset selection
.selectMeters(startMeter, endMeter)
Select stretch by meter distances from linestring start.
.toGeoJSON()
Returns selection GeoJSON
.getSelection()
Returns array of selection L.LatLngs
selection
Selection changed or finished.
reset
Selection cleared
select:start : {pos:
First point set
select:end : {pos:
Second point set
``javascript`
npm install --save leaflet-linestring-select
...
var Select = require('leaflet-linestring-select');
or
``
See /examples/app.js for initialization and other things
- leaflet@>=1.xrbush@>=3.x`
-
The MIT License (MIT)
Copyright (c) 2019 Alexander Milevski
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.