Skip to content

Commit

Permalink
First commit - working version
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiovicar committed Nov 5, 2019
0 parents commit d571157
Show file tree
Hide file tree
Showing 10 changed files with 4,707 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .eslintrc.js
@@ -0,0 +1,34 @@
module.exports = {
'env': {
'browser': true,
'es6': true
},
'extends': 'eslint:recommended',
'globals': {
'Atomics': 'readonly',
'SharedArrayBuffer': 'readonly',
'L': false
},
'parserOptions': {
'ecmaVersion': 2018,
'sourceType': 'module'
},
'rules': {
'indent': [
'error',
4
],
'linebreak-style': [
'error',
'unix'
],
'quotes': [
'error',
'single'
],
'semi': [
'error',
'always'
]
}
};
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
node_modules
npm-debug.log
leaflet.segmentedit.js
leaflet.segmentedit.min.js
21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 LEMAF

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.
86 changes: 86 additions & 0 deletions README
@@ -0,0 +1,86 @@
# Leaflet polyline segment edit

An extension to [Leaflet.draw](https://github.com/Leaflet/Leaflet.draw) to allow editing large polylines one chunk at the time.

Browsers usually can't handle editing large polylines with Leaflet.Draw. Each vertex creates new elements that must be managed and added the DOM: that leads the browser to freeze with too many points. This extension splits the polyline being edited in many segments that can be edited independently.

*Important: this is not a standalone plugin, it requires Leaflet.draw to work.*

Tested on [Leaflet](https://github.com/Leaflet/Leaflet/releases) 1.0.0+ branch.

# QUAL VERSÃO DO DRAW?

Inspired by [https://github.com/openplacedatabase/gmaps-large-polygons](https://github.com/openplacedatabase/gmaps-large-polygons).

## Demos

The plugins works with both L.Polygons (multi or simple, with or without holes) and L.Polylines.

[Editing Brazil (+35k coordinates)](http://www.google.com)

[Multipolygons with holes](http://www.google.com)

[Linestrings](http://www.google.com)

## Installing

## Usage
```js
var options = {
segmentSize: 250,
style: {
default: {
weight: 3,
color: 'tomato'
},
hover: {
weight: 6,
color: 'orange'
},
editing: {
weight: 2,
color: 'gray'
}
}
};

var editor = new L.Edit.PolySegmentEditing(map, poly, options);

// The segments won't show until the handler is enabled
editor.enable();

// After all the work is done
editor.disable();
```

## Options

segmentSize [integer] - The size of each segment. Defaults to `100`.

style.default [object] - The default style for the line segments.

style.hover [object] - Style to display when hovered. Useful for showing which part of the geometry is going to be edited.

style.editing [object] - The style of the segment while being edited.


All the styles default to Leaflet.Draw's default style.

Check [Leaflet's API](https://leafletjs.com/reference-1.5.0.html#path-option) for examples.


## Events

The event `L.Draw.Event.LINESEGMENTEDIT` is fired after a vertex is edited.

You can also listen to `L.Draw.Event.EDITVERTEX`.

## Caveats

This plugin allows polygons with holes to be edited. However, it doesn't enforce the geometry integrity (overlapping holes, holes outside the shell, crossing segments, etc.).

## Thanks

A big thank you to [Leaflet](https://github.com/Leaflet/Leaflet) and [Leaflet.draw](https://github.com/Leaflet/Leaflet.draw) for being so cool and useful.

Thanks to [gmaps-large-polygons](https://github.com/openplacedatabase/gmaps-large-polygons) for the inspiration.
1 change: 1 addition & 0 deletions TODO
@@ -0,0 +1 @@
- Add support to Leaflet 0.7.x

0 comments on commit d571157

Please sign in to comment.