ekylibre-cartography 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +3 -0
- data/Rakefile +10 -0
- data/app/assets/javascripts/cartography.coffee +535 -0
- data/app/assets/javascripts/cartography/base.coffee +11 -0
- data/app/assets/javascripts/cartography/controls.coffee +463 -0
- data/app/assets/javascripts/cartography/events.coffee +36 -0
- data/app/assets/javascripts/cartography/layers.coffee +127 -0
- data/app/assets/javascripts/cartography/layers/simple.coffee +37 -0
- data/app/assets/javascripts/cartography/leaflet/controls.coffee +420 -0
- data/app/assets/javascripts/cartography/leaflet/handlers.coffee +461 -0
- data/app/assets/javascripts/cartography/leaflet/i18n.coffee +31 -0
- data/app/assets/javascripts/cartography/leaflet/layers.coffee +60 -0
- data/app/assets/javascripts/cartography/leaflet/toolbars.coffee +450 -0
- data/app/assets/javascripts/cartography/patches.js +8 -0
- data/app/assets/javascripts/cartography/util.coffee +18 -0
- data/app/assets/javascripts/main.js +18 -0
- data/app/assets/stylesheets/cartography.css +86 -0
- data/app/helpers/cartography_helper.rb +55 -0
- data/lib/cartography.rb +1 -0
- data/lib/cartography/engine.rb +11 -0
- data/lib/cartography/version.rb +3 -0
- data/vendor/assets/components/d3-array/dist/d3-array.js +590 -0
- data/vendor/assets/components/d3-array/dist/d3-array.min.js +2 -0
- data/vendor/assets/components/geojson-equality/dist/geojson-equality.js +295 -0
- data/vendor/assets/components/geojson-equality/dist/geojson-equality.js.map +21 -0
- data/vendor/assets/components/geojson-equality/dist/geojson-equality.min.js +1 -0
- data/vendor/assets/components/leaflet-controlpanel/dist/leaflet.controlpanel.css +29 -0
- data/vendor/assets/components/leaflet-controlpanel/dist/leaflet.controlpanel.js +269 -0
- data/vendor/assets/components/leaflet-draw-cut/dist/leaflet.draw.cut.css +1 -0
- data/vendor/assets/components/leaflet-draw-cut/dist/leaflet.draw.cut.js +8 -0
- data/vendor/assets/components/leaflet-draw-merge/dist/leaflet.draw.merge.css +0 -0
- data/vendor/assets/components/leaflet-draw-merge/dist/leaflet.draw.merge.js +48026 -0
- data/vendor/assets/components/leaflet-draw/dist/leaflet.draw-src.css +326 -0
- data/vendor/assets/components/leaflet-draw/dist/leaflet.draw-src.js +4653 -0
- data/vendor/assets/components/leaflet-draw/dist/leaflet.draw-src.map +1 -0
- data/vendor/assets/components/leaflet-draw/dist/leaflet.draw.css +10 -0
- data/vendor/assets/components/leaflet-draw/dist/leaflet.draw.js +10 -0
- data/vendor/assets/components/leaflet-geographicutil/dist/leaflet.geographicutil.js +3220 -0
- data/vendor/assets/components/leaflet-reactive_measure/dist/reactive_measure.css +30 -0
- data/vendor/assets/components/leaflet-reactive_measure/dist/reactive_measure.js +3764 -0
- data/vendor/assets/components/leaflet/dist/leaflet-src.js +13609 -0
- data/vendor/assets/components/leaflet/dist/leaflet-src.js.map +1 -0
- data/vendor/assets/components/leaflet/dist/leaflet-src.map +1 -0
- data/vendor/assets/components/leaflet/dist/leaflet.css +632 -0
- data/vendor/assets/components/leaflet/dist/leaflet.js +5 -0
- data/vendor/assets/components/leaflet/dist/leaflet.js.map +1 -0
- data/vendor/assets/components/martinez-polygon-clipping/dist/martinez.min.js +9 -0
- data/vendor/assets/components/martinez-polygon-clipping/dist/martinez.umd.js +1716 -0
- data/vendor/assets/components/martinez-polygon-clipping/dist/martinez.umd.js.map +1 -0
- data/vendor/assets/components/polygon-clipping/dist/polygon-clipping.js +279 -0
- data/vendor/assets/components/polygon-clipping/dist/polygon-clipping.min.js +1 -0
- data/vendor/assets/components/rtree/dist/rtree.js +911 -0
- data/vendor/assets/components/rtree/dist/rtree.min.js +1 -0
- data/vendor/assets/components/splaytree/dist/splay.es6.js +765 -0
- data/vendor/assets/components/splaytree/dist/splay.es6.js.map +1 -0
- data/vendor/assets/components/splaytree/dist/splay.js +797 -0
- data/vendor/assets/components/splaytree/dist/splay.js.map +1 -0
- metadata +156 -0
@@ -0,0 +1,461 @@
|
|
1
|
+
((C) ->
|
2
|
+
"use strict"
|
3
|
+
|
4
|
+
L.Selectable = {}
|
5
|
+
L.Selectable.Event = {}
|
6
|
+
L.Selectable.Event.START = "layerSelection:start"
|
7
|
+
L.Selectable.Event.STOP = "layerSelection:stop"
|
8
|
+
L.Selectable.Event.SELECT = "layerSelection:select"
|
9
|
+
L.Selectable.Event.UNSELECT = "layerSelection:unselect"
|
10
|
+
L.Selectable.Event.SELECTED = "layerSelection:selected"
|
11
|
+
|
12
|
+
L.Selectable.Event.Layer = {}
|
13
|
+
L.Selectable.Event.Layer.SELECT = "layerSelection:select"
|
14
|
+
L.Selectable.Event.Layer.UNSELECT = "layerSelection:unselect"
|
15
|
+
|
16
|
+
|
17
|
+
L.SnapEditing = {}
|
18
|
+
L.SnapEditing = {}
|
19
|
+
L.SnapEditing.Event = {}
|
20
|
+
L.SnapEditing.Event.START = "snapedit:start"
|
21
|
+
L.SnapEditing.Event.STOP = "snapedit:stop"
|
22
|
+
L.SnapEditing.Event.SELECT = "snapedit:select"
|
23
|
+
L.SnapEditing.Event.UNSELECT = "snapedit:unselect"
|
24
|
+
L.SnapEditing.Event.EDITED = "snapedit:edited"
|
25
|
+
L.SnapEditing.Event.CHANGE = "snapedit:change"
|
26
|
+
|
27
|
+
class L.LayerSelection extends L.Handler
|
28
|
+
@TYPE: 'LayerSelection'
|
29
|
+
|
30
|
+
options:
|
31
|
+
selectedPathOptions:
|
32
|
+
fill: true
|
33
|
+
#fillColor: '#D84315'
|
34
|
+
#fillOpacity: 0.7
|
35
|
+
color: "#D84315"
|
36
|
+
maintainColor: false
|
37
|
+
|
38
|
+
constructor: (map, options) ->
|
39
|
+
@type = @constructor.TYPE
|
40
|
+
@_map = map
|
41
|
+
super map
|
42
|
+
C.Util.setOptions @, options
|
43
|
+
# Store the selectable layer group for ease of access
|
44
|
+
@_featureGroup = options.featureGroup
|
45
|
+
|
46
|
+
if !(@_featureGroup instanceof L.FeatureGroup)
|
47
|
+
throw new Error('options.featureGroup must be a L.FeatureGroup')
|
48
|
+
|
49
|
+
enable: ->
|
50
|
+
if @_enabled
|
51
|
+
return
|
52
|
+
|
53
|
+
@fire 'enabled', handler: @type
|
54
|
+
|
55
|
+
@_map.fire L.Selectable.Event.START, handler: @type
|
56
|
+
|
57
|
+
super
|
58
|
+
|
59
|
+
@_featureGroup.on 'layeradd', @_enableLayerSelection, @
|
60
|
+
@_featureGroup.on 'layerremove', @_disableLayerSelection, @
|
61
|
+
return
|
62
|
+
|
63
|
+
disable: ->
|
64
|
+
if !@_enabled
|
65
|
+
return
|
66
|
+
@_featureGroup.off 'layeradd', @_enableLayerSelection, @
|
67
|
+
@_featureGroup.off 'layerremove', @_disableLayerSelection, @
|
68
|
+
|
69
|
+
super
|
70
|
+
|
71
|
+
@_map.fire L.Selectable.Event.STOP, handler: @type
|
72
|
+
|
73
|
+
@fire 'disabled', handler: @type
|
74
|
+
return
|
75
|
+
|
76
|
+
addHooks: ->
|
77
|
+
@_featureGroup.eachLayer @_enableLayerSelection, @
|
78
|
+
|
79
|
+
removeHooks: ->
|
80
|
+
@_featureGroup.eachLayer @_disableLayerSelection, @
|
81
|
+
|
82
|
+
save: ->
|
83
|
+
selectedLayers = new L.LayerGroup
|
84
|
+
@_featureGroup.eachLayer (layer) ->
|
85
|
+
if layer.selected
|
86
|
+
selectedLayers.addLayer layer
|
87
|
+
layer.selected = false
|
88
|
+
@_map.fire L.Selectable.Event.SELECTED, layers: selectedLayers
|
89
|
+
return
|
90
|
+
|
91
|
+
_enableLayerSelection: (e) ->
|
92
|
+
layer = e.layer or e.target or e
|
93
|
+
|
94
|
+
#layer.on('click', @_onClick)
|
95
|
+
layer.on('select', @_onClick)
|
96
|
+
#layer.on('touchstart', @_onClick, this)
|
97
|
+
layer.on 'refresh', @_onRefresh, @
|
98
|
+
|
99
|
+
_disableLayerSelection: (e) ->
|
100
|
+
layer = e.layer or e.target or e
|
101
|
+
layer.selected = false
|
102
|
+
# Reset layer styles to that of before select
|
103
|
+
|
104
|
+
if layer.options && layer.options.selecting && layer.options.selecting.className
|
105
|
+
L.DomUtil.removeClass(layer._path, layer.options.selecting.className)
|
106
|
+
else
|
107
|
+
layer.setStyle layer.options.original
|
108
|
+
|
109
|
+
layer.off('click', @_onClick)
|
110
|
+
layer.off('touchstart', @_onClick, this)
|
111
|
+
|
112
|
+
delete layer.options.selecting
|
113
|
+
delete layer.options.original
|
114
|
+
|
115
|
+
_onRefresh: (e) =>
|
116
|
+
layer = e.target
|
117
|
+
return unless layer.options.selecting && layer.options.selecting.className
|
118
|
+
if layer.selected
|
119
|
+
L.DomUtil.addClass(layer._path, layer.options.selecting.className)
|
120
|
+
else
|
121
|
+
L.DomUtil.removeClass(layer._path, layer.options.selecting.className)
|
122
|
+
|
123
|
+
|
124
|
+
_onClick: (e) =>
|
125
|
+
layer = e.target
|
126
|
+
|
127
|
+
if !layer.selected
|
128
|
+
layer.selected = true
|
129
|
+
if !layer.options.selecting && @options.selectedPathOptions
|
130
|
+
pathOptions = L.Util.extend {}, @options.selectedPathOptions
|
131
|
+
# Use the existing color of the layer
|
132
|
+
if pathOptions.maintainColor
|
133
|
+
pathOptions.color = layer.options.color
|
134
|
+
pathOptions.fillColor = layer.options.fillColor
|
135
|
+
layer.options.original = L.extend({}, layer.options)
|
136
|
+
layer.options.selecting = pathOptions
|
137
|
+
|
138
|
+
if layer.options.selecting.className
|
139
|
+
L.DomUtil.addClass(layer._path, layer.options.selecting.className)
|
140
|
+
else
|
141
|
+
layer.setStyle(layer.options.selecting)
|
142
|
+
|
143
|
+
layer.fire L.Selectable.Event.Layer.SELECT
|
144
|
+
@_map.fire L.Selectable.Event.SELECT, layer: layer
|
145
|
+
else
|
146
|
+
layer.selected = false
|
147
|
+
|
148
|
+
if layer.options.selecting.className
|
149
|
+
L.DomUtil.removeClass(layer._path, layer.options.selecting.className)
|
150
|
+
else
|
151
|
+
layer.setStyle(layer.options.original)
|
152
|
+
|
153
|
+
layer.fire L.Selectable.Event.Layer.UNSELECT
|
154
|
+
@_map.fire L.Selectable.Event.UNSELECT, layer: layer
|
155
|
+
|
156
|
+
_hasAvailableLayers: ->
|
157
|
+
@_featureGroup.getLayers().length != 0
|
158
|
+
|
159
|
+
L.LayerSelection.include(L.Mixin.Events)
|
160
|
+
|
161
|
+
class L.Home extends L.Handler
|
162
|
+
@TYPE: 'home'
|
163
|
+
|
164
|
+
options:
|
165
|
+
featureGroup:null
|
166
|
+
|
167
|
+
constructor: (map, options) ->
|
168
|
+
@type = @constructor.TYPE
|
169
|
+
@_map = map
|
170
|
+
super map
|
171
|
+
C.Util.setOptions @, options
|
172
|
+
@_featureGroup = options.featureGroup
|
173
|
+
|
174
|
+
if !(@_featureGroup instanceof L.FeatureGroup)
|
175
|
+
throw new Error('options.featureGroup must be a L.FeatureGroup')
|
176
|
+
|
177
|
+
enable: ->
|
178
|
+
return unless @_hasAvailableLayers
|
179
|
+
|
180
|
+
@_map.fitBounds(@_featureGroup.getBounds())
|
181
|
+
|
182
|
+
super
|
183
|
+
return
|
184
|
+
|
185
|
+
addHooks: (->)
|
186
|
+
|
187
|
+
removeHooks: (->)
|
188
|
+
|
189
|
+
_hasAvailableLayers: ->
|
190
|
+
@_featureGroup.getLayers().length != 0
|
191
|
+
|
192
|
+
L.Home.include(L.Mixin.Events)
|
193
|
+
|
194
|
+
class L.LayerLocking extends L.Handler
|
195
|
+
@TYPE: 'LayerLocking'
|
196
|
+
|
197
|
+
options:
|
198
|
+
tooltip:
|
199
|
+
className: 'leaflet-locking-label'
|
200
|
+
pane: 'markerPane'
|
201
|
+
direction: 'center'
|
202
|
+
permanent: true
|
203
|
+
interactive: false
|
204
|
+
opacity: 1
|
205
|
+
|
206
|
+
constructor: (map, options) ->
|
207
|
+
@type = @constructor.TYPE
|
208
|
+
@_map = map
|
209
|
+
super map
|
210
|
+
C.Util.setOptions @, options
|
211
|
+
@_featureGroup = options.featureGroup
|
212
|
+
|
213
|
+
if !(@_featureGroup instanceof L.FeatureGroup)
|
214
|
+
throw new Error('options.featureGroup must be a L.FeatureGroup')
|
215
|
+
|
216
|
+
enable: ->
|
217
|
+
if @_enabled
|
218
|
+
return
|
219
|
+
|
220
|
+
@fire 'enabled', handler: @type
|
221
|
+
|
222
|
+
#@_map.fire L.Selectable.Event.START, handler: @type
|
223
|
+
|
224
|
+
super
|
225
|
+
|
226
|
+
@_featureGroup.on 'layeradd', @_enableLayerLocking, @
|
227
|
+
@_featureGroup.on 'layerremove', @_disableLayerLocking, @
|
228
|
+
return
|
229
|
+
|
230
|
+
disable: ->
|
231
|
+
if !@_enabled
|
232
|
+
return
|
233
|
+
@_featureGroup.off 'layeradd', @_enableLayerLocking, @
|
234
|
+
@_featureGroup.off 'layerremove', @_disableLayerLocking, @
|
235
|
+
|
236
|
+
super
|
237
|
+
|
238
|
+
#@_map.fire L.Selectable.Event.STOP, handler: @type
|
239
|
+
|
240
|
+
@fire 'disabled', handler: @type
|
241
|
+
return
|
242
|
+
|
243
|
+
addHooks: ->
|
244
|
+
@_featureGroup.eachLayer @_enableLayerLocking, @
|
245
|
+
|
246
|
+
removeHooks: ->
|
247
|
+
@_featureGroup.eachLayer @_disableLayerLocking, @
|
248
|
+
|
249
|
+
_enableLayerLocking: (e) ->
|
250
|
+
layer = e.layer or e.target or e
|
251
|
+
|
252
|
+
layer.on 'lock', @_onLock, @
|
253
|
+
layer.on 'unlock', @_onUnlock, @
|
254
|
+
|
255
|
+
_disableLayerLocking: (e) ->
|
256
|
+
layer = e.layer or e.target or e
|
257
|
+
layer.locked = false
|
258
|
+
|
259
|
+
L.DomUtil.removeClass(layer._path, layer.options.locking.className)
|
260
|
+
|
261
|
+
|
262
|
+
_onLock: (e) =>
|
263
|
+
layer = e.target
|
264
|
+
layer.locked = true
|
265
|
+
L.DomUtil.addClass(layer._path, layer.options.locking.className)
|
266
|
+
|
267
|
+
return unless e.label
|
268
|
+
unless layer.getTooltip()
|
269
|
+
tooltip = new L.Tooltip @options.tooltip
|
270
|
+
layer.bindTooltip(tooltip)
|
271
|
+
|
272
|
+
layer.openTooltip(layer.polylabel())
|
273
|
+
layer.setTooltipContent e.label
|
274
|
+
|
275
|
+
if e.wrapperClassName
|
276
|
+
L.DomUtil.addClass(layer.getTooltip()._container, e.wrapperClassName)
|
277
|
+
|
278
|
+
_onUnlock: (e) =>
|
279
|
+
layer = e.target
|
280
|
+
layer.locked = false
|
281
|
+
L.DomUtil.removeClass(layer._path, layer.options.locking.className)
|
282
|
+
|
283
|
+
layer.closeTooltip()
|
284
|
+
layer.unbindTooltip()
|
285
|
+
|
286
|
+
_hasAvailableLayers: ->
|
287
|
+
@_featureGroup.getLayers().length != 0
|
288
|
+
|
289
|
+
L.LayerLocking.include(L.Mixin.Events)
|
290
|
+
|
291
|
+
class L.EditToolbar.SelectableSnapEdit extends L.EditToolbar.SnapEdit
|
292
|
+
options:
|
293
|
+
snapOptions:
|
294
|
+
snapDistance: 15
|
295
|
+
snapVertices: true
|
296
|
+
|
297
|
+
constructor: (map, options) ->
|
298
|
+
C.Util.setOptions @, options
|
299
|
+
super map, options
|
300
|
+
|
301
|
+
@featureGroup = @options.featureGroup
|
302
|
+
|
303
|
+
@_activeLayer = undefined
|
304
|
+
|
305
|
+
|
306
|
+
if @options.snapOptions
|
307
|
+
L.Util.extend @snapOptions, @options.snapOptions
|
308
|
+
return
|
309
|
+
|
310
|
+
enable: (layer) ->
|
311
|
+
@_enableLayer layer
|
312
|
+
|
313
|
+
@_map.on L.SnapEditing.Event.SELECT, @_editMode, @
|
314
|
+
|
315
|
+
@_map.on L.ReactiveMeasure.Edit.Event.MOVE, @_onEditingPolygon, @
|
316
|
+
|
317
|
+
disable: ->
|
318
|
+
@featureGroup.off 'layeradd', @_enableLayer, @
|
319
|
+
@featureGroup.off 'layerremove', @_disableLayer, @
|
320
|
+
@_map.off L.SnapEditing.Event.SELECT, @_editMode, @
|
321
|
+
@_map.off L.ReactiveMeasure.Edit.Event.MOVE, @_onEditingPolygon, @
|
322
|
+
|
323
|
+
if @_activeLayer && @_activeLayer.editing
|
324
|
+
@_activeLayer.editing.disable()
|
325
|
+
delete @_activeLayer.editing._poly
|
326
|
+
delete @_activeLayer.editing
|
327
|
+
@_disableLayer @_activeLayer
|
328
|
+
|
329
|
+
if @_activeLayer.options._backupLatLngs
|
330
|
+
@_activeLayer.setLatLngs @_activeLayer.options._backupLatLngs
|
331
|
+
delete @_activeLayer.options._backupLatLngs
|
332
|
+
|
333
|
+
@clearGuideLayers()
|
334
|
+
super
|
335
|
+
|
336
|
+
_onEditingPolygon: (e) ->
|
337
|
+
@_map.fire C.Events.shapeDraw.edit, data: { measure: e.measure }
|
338
|
+
|
339
|
+
_enableLayer: (e) ->
|
340
|
+
layer = e.layer or e.target or e
|
341
|
+
|
342
|
+
layer.options.original = L.extend({}, layer.options)
|
343
|
+
|
344
|
+
if @options.disabledPathOptions
|
345
|
+
pathOptions = L.Util.extend {}, @options.disabledPathOptions
|
346
|
+
|
347
|
+
# Use the existing color of the layer
|
348
|
+
if pathOptions.maintainColor
|
349
|
+
pathOptions.color = layer.options.color
|
350
|
+
pathOptions.fillColor = layer.options.fillColor
|
351
|
+
|
352
|
+
layer.options.disabled = pathOptions
|
353
|
+
|
354
|
+
if @options.selectedPathOptions
|
355
|
+
pathOptions = L.Util.extend {}, @options.selectedPathOptions
|
356
|
+
|
357
|
+
# Use the existing color of the layer
|
358
|
+
if pathOptions.maintainColor
|
359
|
+
pathOptions.color = layer.options.color
|
360
|
+
pathOptions.fillColor = layer.options.fillColor
|
361
|
+
|
362
|
+
layer.options.snapSelected = pathOptions
|
363
|
+
|
364
|
+
layer.setStyle layer.options.disabled
|
365
|
+
|
366
|
+
layer.on 'click', @_activate, @
|
367
|
+
|
368
|
+
_activate: (e) ->
|
369
|
+
layer = e.target || e.layer || e
|
370
|
+
|
371
|
+
if !layer.snapSelected
|
372
|
+
layer.snapSelected = true
|
373
|
+
layer.setStyle layer.options.snapSelected
|
374
|
+
|
375
|
+
if @_activeLayer
|
376
|
+
@_unselectLayer @_activeLayer
|
377
|
+
|
378
|
+
@_activeLayer = layer
|
379
|
+
@_backupLayer(@_activeLayer)
|
380
|
+
|
381
|
+
@_map.fire L.SnapEditing.Event.SELECT, layer: @_activeLayer
|
382
|
+
else
|
383
|
+
layer.snapSelected = false
|
384
|
+
layer.setStyle(layer.options.disabled)
|
385
|
+
|
386
|
+
@_activeLayer = null
|
387
|
+
@_map.fire L.SnapEditing.Event.UNSELECT, layer: layer
|
388
|
+
|
389
|
+
_unselectLayer: (e) ->
|
390
|
+
layer = e.layer or e.target or e
|
391
|
+
layer.snapSelected = false
|
392
|
+
if @options.selectedPathOptions
|
393
|
+
layer.setStyle layer.options.disabled
|
394
|
+
|
395
|
+
@_activeLayer = null
|
396
|
+
|
397
|
+
_backupLayer: (layer) ->
|
398
|
+
latlngs = L.LatLngUtil.cloneLatLngs(layer.getLatLngs())
|
399
|
+
layer.options._backupLatLngs = latlngs
|
400
|
+
|
401
|
+
_disableLayer: (e) ->
|
402
|
+
layer = e.layer or e.target or e
|
403
|
+
layer.snapSelected = false
|
404
|
+
# Reset layer styles to that of before select
|
405
|
+
if @options.selectedPathOptions
|
406
|
+
layer.setStyle layer.options.original
|
407
|
+
|
408
|
+
delete layer.options.disabled
|
409
|
+
delete layer.options.snapSelected
|
410
|
+
|
411
|
+
_editMode: (e) ->
|
412
|
+
layer = e.layer
|
413
|
+
if(layer.editing)
|
414
|
+
if layer.editing._poly.editing._verticesHandlers
|
415
|
+
layer.editing._poly.editing._verticesHandlers[0]._markerGroup.clearLayers()
|
416
|
+
delete layer.editing
|
417
|
+
layer.editing = layer.snapediting = new L.Handler.PolylineSnap(layer._map, layer, @options.snapOptions)
|
418
|
+
|
419
|
+
layer.snapediting._guides = []
|
420
|
+
|
421
|
+
if Array.isArray(@snapOptions.guideLayers)
|
422
|
+
@_guideLayers = []
|
423
|
+
for guideLayerGroup in @snapOptions.guideLayers
|
424
|
+
guideLayerGroup.eachLayer (l) =>
|
425
|
+
@addGuideLayer l
|
426
|
+
else if @options.guideLayers instanceof L.LayerGroup
|
427
|
+
@snapOptions.guideLayers.eachLayer (l) =>
|
428
|
+
@addGuideLayer l
|
429
|
+
else
|
430
|
+
@_guideLayers = []
|
431
|
+
|
432
|
+
layer.snapediting.enable()
|
433
|
+
|
434
|
+
layer.editing._poly.on 'editdrag', (e) ->
|
435
|
+
layer = e.target
|
436
|
+
layer._map.fire L.SnapEditing.Event.CHANGE, layer: layer
|
437
|
+
|
438
|
+
addGuideLayer: (layer) ->
|
439
|
+
index = @_guideLayers.findIndex((guideLayer) ->
|
440
|
+
L.stamp(layer) == L.stamp(guideLayer)
|
441
|
+
)
|
442
|
+
|
443
|
+
if index == -1
|
444
|
+
@_guideLayers.push layer
|
445
|
+
@featureGroup.eachLayer (featureLayer) ->
|
446
|
+
if featureLayer.snapediting
|
447
|
+
featureLayer.snapediting._guides.push layer
|
448
|
+
featureLayer.snapediting.addGuideLayer layer
|
449
|
+
return
|
450
|
+
return
|
451
|
+
|
452
|
+
clearGuideLayers: ->
|
453
|
+
@_guideLayers = []
|
454
|
+
@featureGroup.eachLayer (layer) ->
|
455
|
+
if layer.snapediting
|
456
|
+
layer.snapediting._guides = []
|
457
|
+
return
|
458
|
+
return
|
459
|
+
|
460
|
+
|
461
|
+
)(window.Cartography = window.Cartography || {})
|