leaflet-js 0.6.beta4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/CHANGELOG.rdoc +32 -0
- data/LICENSE +21 -0
- data/README.rdoc +54 -0
- data/Rakefile +15 -0
- data/leaflet-js.gemspec +28 -0
- data/lib/leaflet-js.rb +10 -0
- data/lib/leaflet.draw/BREAKINGCHANGES.md +54 -0
- data/lib/leaflet.draw/CHANGELOG.md +73 -0
- data/lib/leaflet.draw/Jakefile.js +26 -0
- data/lib/leaflet.draw/MIT-LICENCE.txt +20 -0
- data/lib/leaflet.draw/README.md +364 -0
- data/lib/leaflet.draw/TODO.md +62 -0
- data/lib/leaflet.draw/build/build.html +243 -0
- data/lib/leaflet.draw/build/build.js +189 -0
- data/lib/leaflet.draw/build/deps.js +75 -0
- data/lib/leaflet.draw/build/hintrc.js +47 -0
- data/lib/leaflet.draw/build/leaflet.draw-include.js +42 -0
- data/lib/leaflet.draw/dist/images/spritesheet.png +0 -0
- data/lib/leaflet.draw/dist/leaflet.draw-src.js +2429 -0
- data/lib/leaflet.draw/dist/leaflet.draw.css +212 -0
- data/lib/leaflet.draw/dist/leaflet.draw.ie.css +44 -0
- data/lib/leaflet.draw/dist/leaflet.draw.js +10 -0
- data/lib/leaflet.draw/examples/basic.html +106 -0
- data/lib/leaflet.draw/examples/edithandlers.html +67 -0
- data/lib/leaflet.draw/examples/libs/images/layers.png +0 -0
- data/lib/leaflet.draw/examples/libs/images/marker-icon.png +0 -0
- data/lib/leaflet.draw/examples/libs/images/marker-icon@2x.png +0 -0
- data/lib/leaflet.draw/examples/libs/images/marker-shadow.png +0 -0
- data/lib/leaflet.draw/examples/libs/leaflet-src.js +8587 -0
- data/lib/leaflet.draw/examples/libs/leaflet.css +459 -0
- data/lib/leaflet.draw/examples/libs/leaflet.ie.css +51 -0
- data/lib/leaflet.draw/package.json +37 -0
- data/lib/leaflet.draw/spec/after.js +2 -0
- data/lib/leaflet.draw/spec/before.js +3 -0
- data/lib/leaflet.draw/spec/expect.js +1253 -0
- data/lib/leaflet.draw/spec/happen.js +93 -0
- data/lib/leaflet.draw/spec/index.html +36 -0
- data/lib/leaflet.draw/spec/karma.conf.js +69 -0
- data/lib/leaflet.draw/spec/sinon.js +4223 -0
- data/lib/leaflet.draw/spec/suites/DrawControlSpec.js +15 -0
- data/lib/leaflet.draw/spec/suites/SpecHelper.js +26 -0
- data/lib/leaflet.draw/src/Control.Draw.js +101 -0
- data/lib/leaflet.draw/src/Leaflet.draw.js +5 -0
- data/lib/leaflet.draw/src/Toolbar.js +187 -0
- data/lib/leaflet.draw/src/Tooltip.js +52 -0
- data/lib/leaflet.draw/src/copyright.js +8 -0
- data/lib/leaflet.draw/src/draw/DrawToolbar.js +107 -0
- data/lib/leaflet.draw/src/draw/handler/Draw.Circle.js +59 -0
- data/lib/leaflet.draw/src/draw/handler/Draw.Feature.js +74 -0
- data/lib/leaflet.draw/src/draw/handler/Draw.Marker.js +97 -0
- data/lib/leaflet.draw/src/draw/handler/Draw.Polygon.js +79 -0
- data/lib/leaflet.draw/src/draw/handler/Draw.Polyline.js +360 -0
- data/lib/leaflet.draw/src/draw/handler/Draw.Rectangle.js +41 -0
- data/lib/leaflet.draw/src/draw/handler/Draw.SimpleShape.js +67 -0
- data/lib/leaflet.draw/src/edit/EditToolbar.js +93 -0
- data/lib/leaflet.draw/src/edit/handler/Edit.Circle.js +63 -0
- data/lib/leaflet.draw/src/edit/handler/Edit.Poly.js +267 -0
- data/lib/leaflet.draw/src/edit/handler/Edit.Rectangle.js +117 -0
- data/lib/leaflet.draw/src/edit/handler/Edit.SimpleShape.js +138 -0
- data/lib/leaflet.draw/src/edit/handler/EditToolbar.Delete.js +109 -0
- data/lib/leaflet.draw/src/edit/handler/EditToolbar.Edit.js +233 -0
- data/lib/leaflet.draw/src/ext/LatLngUtil.js +18 -0
- data/lib/leaflet.draw/src/ext/LineUtil.Intersect.js +15 -0
- data/lib/leaflet.draw/src/ext/Polygon.Intersect.js +27 -0
- data/lib/leaflet.draw/src/ext/Polyline.Intersect.js +85 -0
- data/lib/leaflet.label/CHANGELOG.md +35 -0
- data/lib/leaflet.label/Jakefile.js +21 -0
- data/lib/leaflet.label/MIT-LICENCE.txt +20 -0
- data/lib/leaflet.label/README.md +86 -0
- data/lib/leaflet.label/build/build.js +155 -0
- data/lib/leaflet.label/build/deps.js +24 -0
- data/lib/leaflet.label/build/hint.js +30 -0
- data/lib/leaflet.label/build/hintrc.js +47 -0
- data/lib/leaflet.label/dist/images/death.png +0 -0
- data/lib/leaflet.label/dist/leaflet.label-src.js +359 -0
- data/lib/leaflet.label/dist/leaflet.label.css +33 -0
- data/lib/leaflet.label/dist/leaflet.label.js +9 -0
- data/lib/leaflet.label/example/label.html +82 -0
- data/lib/leaflet.label/libs/leaflet/images/layers.png +0 -0
- data/lib/leaflet.label/libs/leaflet/images/marker-icon.png +0 -0
- data/lib/leaflet.label/libs/leaflet/images/marker-icon@2x.png +0 -0
- data/lib/leaflet.label/libs/leaflet/images/marker-shadow.png +0 -0
- data/lib/leaflet.label/libs/leaflet/leaflet-src.js +8587 -0
- data/lib/leaflet.label/libs/leaflet/leaflet.css +459 -0
- data/lib/leaflet.label/libs/leaflet/leaflet.ie.css +51 -0
- data/lib/leaflet.label/libs/leaflet/leaflet.js +8 -0
- data/lib/leaflet.label/src/FeatureGroup.Label.js +20 -0
- data/lib/leaflet.label/src/Label.js +123 -0
- data/lib/leaflet.label/src/Leaflet.label.js +5 -0
- data/lib/leaflet.label/src/Map.Label.js +7 -0
- data/lib/leaflet.label/src/Marker.Label.js +160 -0
- data/lib/leaflet.label/src/Path.Label.js +55 -0
- data/lib/leaflet.label/src/copyright.js +8 -0
- data/lib/leaflet/CHANGELOG.md +637 -0
- data/lib/leaflet/CONTRIBUTING.md +155 -0
- data/lib/leaflet/Jakefile.js +26 -0
- data/lib/leaflet/LICENSE +23 -0
- data/lib/leaflet/README.md +30 -0
- data/lib/leaflet/build/build.html +243 -0
- data/lib/leaflet/build/build.js +193 -0
- data/lib/leaflet/build/deps.js +256 -0
- data/lib/leaflet/build/hintrc.js +37 -0
- data/lib/leaflet/debug/css/mobile.css +6 -0
- data/lib/leaflet/debug/css/screen.css +5 -0
- data/lib/leaflet/debug/hacks/jitter.html +43 -0
- data/lib/leaflet/debug/leaflet-include.js +59 -0
- data/lib/leaflet/debug/map/canvas.html +47 -0
- data/lib/leaflet/debug/map/controls.html +50 -0
- data/lib/leaflet/debug/map/geolocation.html +35 -0
- data/lib/leaflet/debug/map/image-overlay.html +44 -0
- data/lib/leaflet/debug/map/map-mobile.html +35 -0
- data/lib/leaflet/debug/map/map.html +60 -0
- data/lib/leaflet/debug/map/max-bounds.html +37 -0
- data/lib/leaflet/debug/map/scroll.html +36 -0
- data/lib/leaflet/debug/map/simple-proj.html +45 -0
- data/lib/leaflet/debug/map/wms-marble.html +31 -0
- data/lib/leaflet/debug/map/wms.html +41 -0
- data/lib/leaflet/debug/map/zoomlevels.html +46 -0
- data/lib/leaflet/debug/tests/add_remove_layers.html +88 -0
- data/lib/leaflet/debug/tests/bringtoback.html +38 -0
- data/lib/leaflet/debug/tests/click_on_canvas.html +59 -0
- data/lib/leaflet/debug/tests/click_on_canvas_broken.html +49 -0
- data/lib/leaflet/debug/tests/opacity.html +57 -0
- data/lib/leaflet/debug/tests/remove_while_dragging.html +29 -0
- data/lib/leaflet/debug/tests/removetilewhilepan.html +42 -0
- data/lib/leaflet/debug/tests/reuse_popups.html +41 -0
- data/lib/leaflet/debug/tests/svg_clicks.html +55 -0
- data/lib/leaflet/debug/vector/bounds-extend.html +89 -0
- data/lib/leaflet/debug/vector/feature-group-bounds.html +91 -0
- data/lib/leaflet/debug/vector/geojson-sample.js +53 -0
- data/lib/leaflet/debug/vector/geojson.html +174 -0
- data/lib/leaflet/debug/vector/rectangle.html +54 -0
- data/lib/leaflet/debug/vector/route.js +1 -0
- data/lib/leaflet/debug/vector/touchzoomemu.html +195 -0
- data/lib/leaflet/debug/vector/us-states.js +54 -0
- data/lib/leaflet/debug/vector/vector-bounds.html +70 -0
- data/lib/leaflet/debug/vector/vector-canvas.html +93 -0
- data/lib/leaflet/debug/vector/vector-mobile.html +39 -0
- data/lib/leaflet/debug/vector/vector-simple.html +49 -0
- data/lib/leaflet/debug/vector/vector.html +38 -0
- data/lib/leaflet/dist/images/layers.png +0 -0
- data/lib/leaflet/dist/images/marker-icon-2x.png +0 -0
- data/lib/leaflet/dist/images/marker-icon.png +0 -0
- data/lib/leaflet/dist/images/marker-shadow.png +0 -0
- data/lib/leaflet/dist/leaflet-src.js +8579 -0
- data/lib/leaflet/dist/leaflet.css +459 -0
- data/lib/leaflet/dist/leaflet.ie.css +51 -0
- data/lib/leaflet/dist/leaflet.js +8 -0
- data/lib/leaflet/package.json +22 -0
- data/lib/leaflet/spec/after.js +2 -0
- data/lib/leaflet/spec/before.js +3 -0
- data/lib/leaflet/spec/expect.js +1253 -0
- data/lib/leaflet/spec/happen.js +93 -0
- data/lib/leaflet/spec/index.html +78 -0
- data/lib/leaflet/spec/karma.conf.js +64 -0
- data/lib/leaflet/spec/sinon.js +4223 -0
- data/lib/leaflet/spec/suites/LeafletSpec.js +13 -0
- data/lib/leaflet/spec/suites/SpecHelper.js +26 -0
- data/lib/leaflet/spec/suites/control/Control.AttributionSpec.js +68 -0
- data/lib/leaflet/spec/suites/control/Control.LayersSpec.js +67 -0
- data/lib/leaflet/spec/suites/control/Control.ScaleSpec.js +6 -0
- data/lib/leaflet/spec/suites/core/ClassSpec.js +156 -0
- data/lib/leaflet/spec/suites/core/EventsSpec.js +336 -0
- data/lib/leaflet/spec/suites/core/UtilSpec.js +212 -0
- data/lib/leaflet/spec/suites/dom/DomEventSpec.js +102 -0
- data/lib/leaflet/spec/suites/dom/DomUtilSpec.js +89 -0
- data/lib/leaflet/spec/suites/geo/LatLngBoundsSpec.js +136 -0
- data/lib/leaflet/spec/suites/geo/LatLngSpec.js +118 -0
- data/lib/leaflet/spec/suites/geo/ProjectionSpec.js +47 -0
- data/lib/leaflet/spec/suites/geometry/BoundsSpec.js +87 -0
- data/lib/leaflet/spec/suites/geometry/LineUtilSpec.js +75 -0
- data/lib/leaflet/spec/suites/geometry/PointSpec.js +104 -0
- data/lib/leaflet/spec/suites/geometry/PolyUtilSpec.js +27 -0
- data/lib/leaflet/spec/suites/geometry/TransformationSpec.js +31 -0
- data/lib/leaflet/spec/suites/layer/FeatureGroupSpec.js +36 -0
- data/lib/leaflet/spec/suites/layer/GeoJSONSpec.js +86 -0
- data/lib/leaflet/spec/suites/layer/LayerGroupSpec.js +58 -0
- data/lib/leaflet/spec/suites/layer/PopupSpec.js +59 -0
- data/lib/leaflet/spec/suites/layer/TileLayerSpec.js +87 -0
- data/lib/leaflet/spec/suites/layer/vector/CircleMarkerSpec.js +53 -0
- data/lib/leaflet/spec/suites/layer/vector/CircleSpec.js +17 -0
- data/lib/leaflet/spec/suites/layer/vector/PolygonSpec.js +55 -0
- data/lib/leaflet/spec/suites/layer/vector/PolylineGeometrySpec.js +35 -0
- data/lib/leaflet/spec/suites/layer/vector/PolylineSpec.js +55 -0
- data/lib/leaflet/spec/suites/map/MapSpec.js +244 -0
- data/lib/leaflet/src/Leaflet.js +23 -0
- data/lib/leaflet/src/control/Control.Attribution.js +115 -0
- data/lib/leaflet/src/control/Control.Layers.js +243 -0
- data/lib/leaflet/src/control/Control.Scale.js +112 -0
- data/lib/leaflet/src/control/Control.Zoom.js +86 -0
- data/lib/leaflet/src/control/Control.js +107 -0
- data/lib/leaflet/src/copyright.js +4 -0
- data/lib/leaflet/src/core/Browser.js +96 -0
- data/lib/leaflet/src/core/Class.js +106 -0
- data/lib/leaflet/src/core/Events.js +174 -0
- data/lib/leaflet/src/core/Handler.js +28 -0
- data/lib/leaflet/src/core/Util.js +182 -0
- data/lib/leaflet/src/dom/DomEvent.DoubleTap.js +103 -0
- data/lib/leaflet/src/dom/DomEvent.MsTouch.js +146 -0
- data/lib/leaflet/src/dom/DomEvent.js +211 -0
- data/lib/leaflet/src/dom/DomUtil.js +239 -0
- data/lib/leaflet/src/dom/Draggable.js +198 -0
- data/lib/leaflet/src/dom/PosAnimation.Timer.js +67 -0
- data/lib/leaflet/src/dom/PosAnimation.js +83 -0
- data/lib/leaflet/src/geo/LatLng.js +88 -0
- data/lib/leaflet/src/geo/LatLngBounds.js +153 -0
- data/lib/leaflet/src/geo/crs/CRS.EPSG3395.js +14 -0
- data/lib/leaflet/src/geo/crs/CRS.EPSG3857.js +21 -0
- data/lib/leaflet/src/geo/crs/CRS.EPSG4326.js +10 -0
- data/lib/leaflet/src/geo/crs/CRS.Simple.js +12 -0
- data/lib/leaflet/src/geo/crs/CRS.js +27 -0
- data/lib/leaflet/src/geo/projection/Projection.LonLat.js +13 -0
- data/lib/leaflet/src/geo/projection/Projection.Mercator.js +56 -0
- data/lib/leaflet/src/geo/projection/Projection.SphericalMercator.js +27 -0
- data/lib/leaflet/src/geo/projection/Projection.js +5 -0
- data/lib/leaflet/src/geometry/Bounds.js +95 -0
- data/lib/leaflet/src/geometry/LineUtil.js +202 -0
- data/lib/leaflet/src/geometry/Point.js +119 -0
- data/lib/leaflet/src/geometry/PolyUtil.js +55 -0
- data/lib/leaflet/src/geometry/Transformation.js +31 -0
- data/lib/leaflet/src/images/marker.svg +1 -0
- data/lib/leaflet/src/layer/FeatureGroup.js +81 -0
- data/lib/leaflet/src/layer/GeoJSON.js +245 -0
- data/lib/leaflet/src/layer/ImageOverlay.js +132 -0
- data/lib/leaflet/src/layer/LayerGroup.js +110 -0
- data/lib/leaflet/src/layer/Popup.js +316 -0
- data/lib/leaflet/src/layer/marker/DivIcon.js +43 -0
- data/lib/leaflet/src/layer/marker/Icon.Default.js +51 -0
- data/lib/leaflet/src/layer/marker/Icon.js +101 -0
- data/lib/leaflet/src/layer/marker/Marker.Drag.js +66 -0
- data/lib/leaflet/src/layer/marker/Marker.Popup.js +72 -0
- data/lib/leaflet/src/layer/marker/Marker.js +275 -0
- data/lib/leaflet/src/layer/tile/TileLayer.Anim.js +117 -0
- data/lib/leaflet/src/layer/tile/TileLayer.Canvas.js +60 -0
- data/lib/leaflet/src/layer/tile/TileLayer.WMS.js +83 -0
- data/lib/leaflet/src/layer/tile/TileLayer.js +578 -0
- data/lib/leaflet/src/layer/vector/Circle.js +98 -0
- data/lib/leaflet/src/layer/vector/CircleMarker.js +33 -0
- data/lib/leaflet/src/layer/vector/MultiPoly.js +47 -0
- data/lib/leaflet/src/layer/vector/Path.Popup.js +65 -0
- data/lib/leaflet/src/layer/vector/Path.SVG.js +219 -0
- data/lib/leaflet/src/layer/vector/Path.VML.js +125 -0
- data/lib/leaflet/src/layer/vector/Path.js +115 -0
- data/lib/leaflet/src/layer/vector/Polygon.js +81 -0
- data/lib/leaflet/src/layer/vector/Polyline.js +164 -0
- data/lib/leaflet/src/layer/vector/Rectangle.js +27 -0
- data/lib/leaflet/src/layer/vector/canvas/Circle.Canvas.js +18 -0
- data/lib/leaflet/src/layer/vector/canvas/Path.Canvas.js +196 -0
- data/lib/leaflet/src/layer/vector/canvas/Polygon.Canvas.js +37 -0
- data/lib/leaflet/src/layer/vector/canvas/Polyline.Canvas.js +30 -0
- data/lib/leaflet/src/map/Map.js +743 -0
- data/lib/leaflet/src/map/anim/Map.PanAnimation.js +88 -0
- data/lib/leaflet/src/map/anim/Map.ZoomAnimation.js +90 -0
- data/lib/leaflet/src/map/ext/Map.Geolocation.js +91 -0
- data/lib/leaflet/src/map/handler/Map.BoxZoom.js +104 -0
- data/lib/leaflet/src/map/handler/Map.DoubleClickZoom.js +23 -0
- data/lib/leaflet/src/map/handler/Map.Drag.js +146 -0
- data/lib/leaflet/src/map/handler/Map.Keyboard.js +147 -0
- data/lib/leaflet/src/map/handler/Map.ScrollWheelZoom.js +56 -0
- data/lib/leaflet/src/map/handler/Map.TouchZoom.js +121 -0
- data/vendor/assets/images/layers.png +0 -0
- data/vendor/assets/images/marker-icon-2x.png +0 -0
- data/vendor/assets/images/marker-icon.png +0 -0
- data/vendor/assets/images/marker-shadow.png +0 -0
- data/vendor/assets/images/spritesheet.png +0 -0
- data/vendor/assets/javascripts/leaflet.draw.js +39 -0
- data/vendor/assets/javascripts/leaflet.js +145 -0
- data/vendor/assets/javascripts/leaflet.label.js +9 -0
- data/vendor/assets/stylesheets/leaflet.css.erb +459 -0
- data/vendor/assets/stylesheets/leaflet.draw.css.erb +212 -0
- data/vendor/assets/stylesheets/leaflet.draw.ie.css +44 -0
- data/vendor/assets/stylesheets/leaflet.ie.css +51 -0
- data/vendor/assets/stylesheets/leaflet.label.css +33 -0
- metadata +317 -0
@@ -0,0 +1,212 @@
|
|
1
|
+
/* ================================================================== */
|
2
|
+
/* Toolbars
|
3
|
+
/* ================================================================== */
|
4
|
+
|
5
|
+
.leaflet-draw-section {
|
6
|
+
position: relative;
|
7
|
+
}
|
8
|
+
|
9
|
+
.leaflet-draw-toolbar {
|
10
|
+
margin-top: 12px;
|
11
|
+
}
|
12
|
+
|
13
|
+
.leaflet-draw-toolbar-top {
|
14
|
+
margin-top: 0;
|
15
|
+
}
|
16
|
+
|
17
|
+
.leaflet-draw-toolbar-notop a:first-child {
|
18
|
+
border-top-right-radius: 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
.leaflet-draw-toolbar-nobottom a:last-child {
|
22
|
+
border-bottom-right-radius: 0;
|
23
|
+
}
|
24
|
+
|
25
|
+
.leaflet-draw-toolbar a {
|
26
|
+
background-image: url('images/spritesheet.png');
|
27
|
+
background-repeat: no-repeat;
|
28
|
+
}
|
29
|
+
|
30
|
+
.leaflet-draw a {
|
31
|
+
display: block;
|
32
|
+
text-align: center;
|
33
|
+
text-decoration: none;
|
34
|
+
}
|
35
|
+
|
36
|
+
/* ================================================================== */
|
37
|
+
/* Toolbar actions menu
|
38
|
+
/* ================================================================== */
|
39
|
+
|
40
|
+
.leaflet-draw-actions {
|
41
|
+
display: none;
|
42
|
+
list-style: none;
|
43
|
+
margin: 0;
|
44
|
+
padding: 0;
|
45
|
+
position: absolute;
|
46
|
+
left: 26px; /* leaflet-draw-toolbar.left + leaflet-draw-toolbar.width */
|
47
|
+
top: 0;
|
48
|
+
}
|
49
|
+
|
50
|
+
.leaflet-draw-actions li {
|
51
|
+
float: left;
|
52
|
+
}
|
53
|
+
|
54
|
+
.leaflet-draw-actions li:first-child a {
|
55
|
+
border-left: none;
|
56
|
+
}
|
57
|
+
|
58
|
+
.leaflet-draw-actions li:last-child a {
|
59
|
+
-webkit-border-radius: 0 4px 4px 0;
|
60
|
+
border-radius: 0 4px 4px 0;
|
61
|
+
}
|
62
|
+
|
63
|
+
.leaflet-draw-actions a {
|
64
|
+
background-color: #919187;
|
65
|
+
border-left: 1px solid #AAA;
|
66
|
+
color: #FFF;
|
67
|
+
font: 11px/19px "Helvetica Neue", Arial, Helvetica, sans-serif;
|
68
|
+
line-height: 28px;
|
69
|
+
text-decoration: none;
|
70
|
+
width: 50px;
|
71
|
+
height: 28px;
|
72
|
+
}
|
73
|
+
|
74
|
+
.leaflet-draw-actions-bottom {
|
75
|
+
margin-top: 0;
|
76
|
+
}
|
77
|
+
|
78
|
+
.leaflet-draw-actions-top {
|
79
|
+
margin-top: 1px;
|
80
|
+
}
|
81
|
+
|
82
|
+
.leaflet-draw-actions-top a,
|
83
|
+
.leaflet-draw-actions-bottom a {
|
84
|
+
height: 27px;
|
85
|
+
line-height: 27px;
|
86
|
+
}
|
87
|
+
|
88
|
+
.leaflet-draw-actions a:hover {
|
89
|
+
background-color: #A0A098;
|
90
|
+
}
|
91
|
+
|
92
|
+
.leaflet-draw-actions-top.leaflet-draw-actions-bottom a {
|
93
|
+
height: 26px;
|
94
|
+
line-height: 26px;
|
95
|
+
}
|
96
|
+
|
97
|
+
/* ================================================================== */
|
98
|
+
/* Draw toolbar
|
99
|
+
/* ================================================================== */
|
100
|
+
|
101
|
+
.leaflet-draw-toolbar .leaflet-draw-draw-polyline {
|
102
|
+
background-position: -2px -2px;
|
103
|
+
}
|
104
|
+
|
105
|
+
.leaflet-draw-toolbar .leaflet-draw-draw-polygon {
|
106
|
+
background-position: -31px -2px;
|
107
|
+
}
|
108
|
+
|
109
|
+
.leaflet-draw-toolbar .leaflet-draw-draw-rectangle {
|
110
|
+
background-position: -62px -2px;
|
111
|
+
}
|
112
|
+
|
113
|
+
.leaflet-draw-toolbar .leaflet-draw-draw-circle {
|
114
|
+
background-position: -92px -2px;
|
115
|
+
}
|
116
|
+
|
117
|
+
.leaflet-draw-toolbar .leaflet-draw-draw-marker {
|
118
|
+
background-position: -122px -2px;
|
119
|
+
}
|
120
|
+
|
121
|
+
/* ================================================================== */
|
122
|
+
/* Edit toolbar
|
123
|
+
/* ================================================================== */
|
124
|
+
|
125
|
+
.leaflet-draw-toolbar .leaflet-draw-edit-edit {
|
126
|
+
background-position: -152px -2px;
|
127
|
+
}
|
128
|
+
|
129
|
+
.leaflet-draw-toolbar .leaflet-draw-edit-remove {
|
130
|
+
background-position: -182px -2px;
|
131
|
+
}
|
132
|
+
|
133
|
+
/* ================================================================== */
|
134
|
+
/* Drawing styles
|
135
|
+
/* ================================================================== */
|
136
|
+
|
137
|
+
.leaflet-mouse-marker {
|
138
|
+
background-color: #fff;
|
139
|
+
cursor: crosshair;
|
140
|
+
}
|
141
|
+
|
142
|
+
.leaflet-draw-tooltip {
|
143
|
+
background: rgb(54, 54, 54);
|
144
|
+
background: rgba(0, 0, 0, 0.5);
|
145
|
+
border: 1px solid transparent;
|
146
|
+
-webkit-border-radius: 4px;
|
147
|
+
border-radius: 4px;
|
148
|
+
color: #fff;
|
149
|
+
font: 12px/18px "Helvetica Neue", Arial, Helvetica, sans-serif;
|
150
|
+
margin-left: 20px;
|
151
|
+
margin-top: -21px;
|
152
|
+
padding: 4px 8px;
|
153
|
+
position: absolute;
|
154
|
+
white-space: nowrap;
|
155
|
+
z-index: 6;
|
156
|
+
}
|
157
|
+
|
158
|
+
.leaflet-draw-tooltip:before {
|
159
|
+
border-right: 6px solid black;
|
160
|
+
border-right-color: rgba(0, 0, 0, 0.5);
|
161
|
+
border-top: 6px solid transparent;
|
162
|
+
border-bottom: 6px solid transparent;
|
163
|
+
content: "";
|
164
|
+
position: absolute;
|
165
|
+
top: 7px;
|
166
|
+
left: -7px;
|
167
|
+
}
|
168
|
+
|
169
|
+
.leaflet-error-draw-tooltip {
|
170
|
+
background-color: #F2DEDE;
|
171
|
+
border: 1px solid #E6B6BD;
|
172
|
+
color: #B94A48;
|
173
|
+
}
|
174
|
+
|
175
|
+
.leaflet-error-draw-tooltip:before {
|
176
|
+
border-right-color: #E6B6BD;
|
177
|
+
}
|
178
|
+
|
179
|
+
.leaflet-draw-tooltip-single {
|
180
|
+
margin-top: -12px
|
181
|
+
}
|
182
|
+
|
183
|
+
.leaflet-draw-tooltip-subtext {
|
184
|
+
color: #f8d5e4;
|
185
|
+
}
|
186
|
+
|
187
|
+
.leaflet-draw-guide-dash {
|
188
|
+
font-size: 1%;
|
189
|
+
opacity: 0.6;
|
190
|
+
position: absolute;
|
191
|
+
width: 5px;
|
192
|
+
height: 5px;
|
193
|
+
}
|
194
|
+
|
195
|
+
/* ================================================================== */
|
196
|
+
/* Edit styles
|
197
|
+
/* ================================================================== */
|
198
|
+
|
199
|
+
.leaflet-edit-marker-selected {
|
200
|
+
background: rgba(254, 87, 161, 0.1);
|
201
|
+
border: 4px dashed rgba(254, 87, 161, 0.6);
|
202
|
+
-webkit-border-radius: 4px;
|
203
|
+
border-radius: 4px;
|
204
|
+
}
|
205
|
+
|
206
|
+
.leaflet-edit-move {
|
207
|
+
cursor: move;
|
208
|
+
}
|
209
|
+
|
210
|
+
.leaflet-edit-resize {
|
211
|
+
cursor: pointer;
|
212
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
/* Conditional stylesheet for IE. */
|
2
|
+
|
3
|
+
.leaflet-draw-toolbar {
|
4
|
+
border: 3px solid #999;
|
5
|
+
}
|
6
|
+
|
7
|
+
.leaflet-draw-toolbar a {
|
8
|
+
background-color: #eee;
|
9
|
+
}
|
10
|
+
|
11
|
+
.leaflet-draw-toolbar a:hover {
|
12
|
+
background-color: #fff;
|
13
|
+
}
|
14
|
+
|
15
|
+
.leaflet-draw-actions {
|
16
|
+
left: 32px;
|
17
|
+
margin-top: 3px;
|
18
|
+
}
|
19
|
+
|
20
|
+
.leaflet-edit-marker-selected {
|
21
|
+
border: 4px dashed #fe93c2;
|
22
|
+
}
|
23
|
+
|
24
|
+
.leaflet-draw-actions a {
|
25
|
+
background-color: #999;
|
26
|
+
}
|
27
|
+
|
28
|
+
.leaflet-draw-actions a:hover {
|
29
|
+
background-color: #a5a5a5;
|
30
|
+
}
|
31
|
+
|
32
|
+
.leaflet-draw-actions-top a {
|
33
|
+
margin-top: 1px;
|
34
|
+
}
|
35
|
+
|
36
|
+
.leaflet-draw-actions-bottom a {
|
37
|
+
height: 28px;
|
38
|
+
line-height: 28px;
|
39
|
+
}
|
40
|
+
|
41
|
+
.leaflet-draw-actions-top.leaflet-draw-actions-bottom a {
|
42
|
+
height: 27px;
|
43
|
+
line-height: 27px;
|
44
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
/*
|
2
|
+
Leaflet.draw, a plugin that adds drawing and editing tools to Leaflet powered maps.
|
3
|
+
(c) 2012-2013, Jacob Toye, Smartrak
|
4
|
+
|
5
|
+
https://github.com/Leaflet/Leaflet.draw
|
6
|
+
http://leafletjs.com
|
7
|
+
https://github.com/jacobtoye
|
8
|
+
*/
|
9
|
+
(function(t,e){L.drawVersion="0.2.0-dev",L.Draw={},L.Draw.Feature=L.Handler.extend({includes:L.Mixin.Events,initialize:function(t,e){this._map=t,this._container=t._container,this._overlayPane=t._panes.overlayPane,this._popupPane=t._panes.popupPane,e&&e.shapeOptions&&(e.shapeOptions=L.Util.extend({},this.options.shapeOptions,e.shapeOptions)),L.Util.extend(this.options,e)},enable:function(){this._enabled||(L.Handler.prototype.enable.call(this),this.fire("enabled",{handler:this.type}),this._map.fire("draw:drawstart",{layerType:this.type}))},disable:function(){this._enabled&&(L.Handler.prototype.disable.call(this),this.fire("disabled",{handler:this.type}),this._map.fire("draw:drawstop",{layerType:this.type}))},addHooks:function(){this._map&&(L.DomUtil.disableTextSelection(),this._tooltip=new L.Tooltip(this._map),L.DomEvent.addListener(this._container,"keyup",this._cancelDrawing,this))},removeHooks:function(){this._map&&(L.DomUtil.enableTextSelection(),this._tooltip.dispose(),this._tooltip=null,L.DomEvent.removeListener(this._container,"keyup",this._cancelDrawing))},setOptions:function(t){L.setOptions(this,t)},_fireCreatedEvent:function(t){this._map.fire("draw:created",{layer:t,layerType:this.type})},_cancelDrawing:function(t){27===t.keyCode&&this.disable()}}),L.Draw.Polyline=L.Draw.Feature.extend({statics:{TYPE:"polyline"},Poly:L.Polyline,options:{allowIntersection:!0,drawError:{color:"#b00b00",message:"<strong>Error:</strong> shape edges cannot cross!",timeout:2500},icon:new L.DivIcon({iconSize:new L.Point(8,8),className:"leaflet-div-icon leaflet-editing-icon"}),guidelineDistance:20,shapeOptions:{stroke:!0,color:"#f06eaa",weight:4,opacity:.5,fill:!1,clickable:!0},zIndexOffset:2e3},initialize:function(t,e){e&&e.drawError&&(e.drawError=L.Util.extend({},this.options.drawError,e.drawError)),this.type=L.Draw.Polyline.TYPE,L.Draw.Feature.prototype.initialize.call(this,t,e)},addHooks:function(){L.Draw.Feature.prototype.addHooks.call(this),this._map&&(this._markers=[],this._markerGroup=new L.LayerGroup,this._map.addLayer(this._markerGroup),this._poly=new L.Polyline([],this.options.shapeOptions),this._tooltip.updateContent(this._getTooltipText()),this._mouseMarker||(this._mouseMarker=L.marker(this._map.getCenter(),{icon:L.divIcon({className:"leaflet-mouse-marker",iconAnchor:[20,20],iconSize:[40,40]}),opacity:0,zIndexOffset:this.options.zIndexOffset})),this._mouseMarker.on("click",this._onClick,this).addTo(this._map),this._map.on("mousemove",this._onMouseMove,this).on("zoomend",this._onZoomEnd,this))},removeHooks:function(){L.Draw.Feature.prototype.removeHooks.call(this),this._clearHideErrorTimeout(),this._cleanUpShape(),this._map.removeLayer(this._markerGroup),delete this._markerGroup,delete this._markers,this._map.removeLayer(this._poly),delete this._poly,this._mouseMarker.off("click",this._onClick,this),this._map.removeLayer(this._mouseMarker),delete this._mouseMarker,this._clearGuides(),this._map.off("mousemove",this._onMouseMove,this).off("zoomend",this._onZoomEnd,this)},_finishShape:function(){var t=this._poly.newLatLngIntersects(this._poly.getLatLngs()[0],!0);return!this.options.allowIntersection&&t||!this._shapeIsValid()?(this._showErrorTooltip(),undefined):(this._fireCreatedEvent(),this.disable(),undefined)},_shapeIsValid:function(){return!0},_onZoomEnd:function(){this._updateGuide()},_onMouseMove:function(t){var e=t.layerPoint,i=t.latlng;this._currentLatLng=i,this._tooltip.updatePosition(i),this._updateGuide(e),this._mouseMarker.setLatLng(i),L.DomEvent.preventDefault(t.originalEvent)},_onClick:function(t){var e=t.target.getLatLng(),i=this._markers.length;return i>0&&!this.options.allowIntersection&&this._poly.newLatLngIntersects(e)?(this._showErrorTooltip(),undefined):(this._errorShown&&this._hideErrorTooltip(),this._markers.push(this._createMarker(e)),this._poly.addLatLng(e),2===this._poly.getLatLngs().length&&this._map.addLayer(this._poly),this._updateFinishHandler(),this._vertexAdded(e),this._clearGuides(),undefined)},_updateFinishHandler:function(){var t=this._markers.length;t>1&&this._markers[t-1].on("click",this._finishShape,this),t>2&&this._markers[t-2].off("click",this._finishShape,this)},_createMarker:function(t){var e=new L.Marker(t,{icon:this.options.icon,zIndexOffset:2*this.options.zIndexOffset});return this._markerGroup.addLayer(e),e},_updateGuide:function(t){t=t||this._map.latLngToLayerPoint(this._currentLatLng);var e=this._markers.length;e>0&&(this._errorShown||this._tooltip.updateContent(this._getTooltipText()),this._clearGuides(),this._drawGuide(this._map.latLngToLayerPoint(this._markers[e-1].getLatLng()),t))},_drawGuide:function(t,e){var i,o,s,a,n=Math.floor(Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)));for(this._guidesContainer||(this._guidesContainer=L.DomUtil.create("div","leaflet-draw-guides",this._overlayPane)),i=this.options.guidelineDistance;n>i;i+=this.options.guidelineDistance)o=i/n,s={x:Math.floor(t.x*(1-o)+o*e.x),y:Math.floor(t.y*(1-o)+o*e.y)},a=L.DomUtil.create("div","leaflet-draw-guide-dash",this._guidesContainer),a.style.backgroundColor=this._errorShown?this.options.drawError.color:this.options.shapeOptions.color,L.DomUtil.setPosition(a,s)},_updateGuideColor:function(t){if(this._guidesContainer)for(var e=0,i=this._guidesContainer.childNodes.length;i>e;e++)this._guidesContainer.childNodes[e].style.backgroundColor=t},_clearGuides:function(){if(this._guidesContainer)for(;this._guidesContainer.firstChild;)this._guidesContainer.removeChild(this._guidesContainer.firstChild)},_getTooltipText:function(){var t,e,i;return 0===this._markers.length?t={text:"Click to start drawing line."}:(e=this._measurementRunningTotal+this._currentLatLng.distanceTo(this._markers[this._markers.length-1].getLatLng()),i=e>1e3?(e/1e3).toFixed(2)+" km":Math.ceil(e)+" m",t=1===this._markers.length?{text:"Click to continue drawing line.",subtext:i}:{text:"Click last point to finish line.",subtext:i}),t},_showErrorTooltip:function(){this._errorShown=!0,this._tooltip.showAsError().updateContent({text:this.options.drawError.message}),this._updateGuideColor(this.options.drawError.color),this._poly.setStyle({color:this.options.drawError.color}),this._clearHideErrorTimeout(),this._hideErrorTimeout=setTimeout(L.Util.bind(this._hideErrorTooltip,this),this.options.drawError.timeout)},_hideErrorTooltip:function(){this._errorShown=!1,this._clearHideErrorTimeout(),this._tooltip.removeError().updateContent(this._getTooltipText()),this._updateGuideColor(this.options.shapeOptions.color),this._poly.setStyle({color:this.options.shapeOptions.color})},_clearHideErrorTimeout:function(){this._hideErrorTimeout&&(clearTimeout(this._hideErrorTimeout),this._hideErrorTimeout=null)},_vertexAdded:function(t){1===this._markers.length?this._measurementRunningTotal=0:this._measurementRunningTotal+=t.distanceTo(this._markers[this._markers.length-2].getLatLng())},_cleanUpShape:function(){this._markers.length>0&&this._markers[this._markers.length-1].off("click",this._finishShape,this)},_fireCreatedEvent:function(){var t=new this.Poly(this._poly.getLatLngs(),this.options.shapeOptions);L.Draw.Feature.prototype._fireCreatedEvent.call(this,t)}}),L.Draw.Polygon=L.Draw.Polyline.extend({statics:{TYPE:"polygon"},Poly:L.Polygon,options:{shapeOptions:{stroke:!0,color:"#f06eaa",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0}},initialize:function(t,e){L.Draw.Polyline.prototype.initialize.call(this,t,e),this.type=L.Draw.Polygon.TYPE},_updateFinishHandler:function(){var t=this._markers.length;1===t&&this._markers[0].on("click",this._finishShape,this),t>2&&(this._markers[t-1].on("dblclick",this._finishShape,this),t>3&&this._markers[t-2].off("dblclick",this._finishShape,this))},_getTooltipText:function(){var t;return t=0===this._markers.length?"Click to start drawing shape.":3>this._markers.length?"Click to continue drawing shape.":"Double click to close this shape.",{text:t}},_shapeIsValid:function(){return this._markers.length>=3},_vertexAdded:function(){},_cleanUpShape:function(){var t=this._markers.length;t>0&&(this._markers[0].off("click",this._finishShape,this),t>2&&this._markers[t-1].off("dblclick",this._finishShape,this))}}),L.SimpleShape={},L.Draw.SimpleShape=L.Draw.Feature.extend({addHooks:function(){L.Draw.Feature.prototype.addHooks.call(this),this._map&&(this._map.dragging.disable(),this._container.style.cursor="crosshair",this._tooltip.updateContent({text:this._initialLabelText}),this._map.on("mousedown",this._onMouseDown,this).on("mousemove",this._onMouseMove,this))},removeHooks:function(){L.Draw.Feature.prototype.removeHooks.call(this),this._map&&(this._map.dragging.enable(),this._container.style.cursor="",this._map.off("mousedown",this._onMouseDown,this).off("mousemove",this._onMouseMove,this),L.DomEvent.off(e,"mouseup",this._onMouseUp),this._shape&&(this._map.removeLayer(this._shape),delete this._shape)),this._isDrawing=!1},_onMouseDown:function(t){this._isDrawing=!0,this._startLatLng=t.latlng,L.DomEvent.on(e,"mouseup",this._onMouseUp,this).preventDefault(t.originalEvent)},_onMouseMove:function(t){var e=t.latlng;this._tooltip.updatePosition(e),this._isDrawing&&(this._tooltip.updateContent({text:"Release mouse to finish drawing."}),this._drawShape(e))},_onMouseUp:function(){this._shape&&this._fireCreatedEvent(),this.disable()}}),L.Draw.Rectangle=L.Draw.SimpleShape.extend({statics:{TYPE:"rectangle"},options:{shapeOptions:{stroke:!0,color:"#f06eaa",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0}},initialize:function(t,e){this.type=L.Draw.Rectangle.TYPE,L.Draw.SimpleShape.prototype.initialize.call(this,t,e)},_initialLabelText:"Click and drag to draw rectangle.",_drawShape:function(t){this._shape?this._shape.setBounds(new L.LatLngBounds(this._startLatLng,t)):(this._shape=new L.Rectangle(new L.LatLngBounds(this._startLatLng,t),this.options.shapeOptions),this._map.addLayer(this._shape))},_fireCreatedEvent:function(){var t=new L.Rectangle(this._shape.getBounds(),this.options.shapeOptions);L.Draw.SimpleShape.prototype._fireCreatedEvent.call(this,t)}}),L.Draw.Circle=L.Draw.SimpleShape.extend({statics:{TYPE:"circle"},options:{shapeOptions:{stroke:!0,color:"#f06eaa",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0}},initialize:function(t,e){this.type=L.Draw.Circle.TYPE,L.Draw.SimpleShape.prototype.initialize.call(this,t,e)},_initialLabelText:"Click and drag to draw circle.",_drawShape:function(t){this._shape?this._shape.setRadius(this._startLatLng.distanceTo(t)):(this._shape=new L.Circle(this._startLatLng,this._startLatLng.distanceTo(t),this.options.shapeOptions),this._map.addLayer(this._shape))},_fireCreatedEvent:function(){var t=new L.Circle(this._startLatLng,this._shape.getRadius(),this.options.shapeOptions);L.Draw.SimpleShape.prototype._fireCreatedEvent.call(this,t)},_onMouseMove:function(t){var e,i=t.latlng;this._tooltip.updatePosition(i),this._isDrawing&&(this._drawShape(i),e=this._shape.getRadius().toFixed(1),this._tooltip.updateContent({text:"Release mouse to finish drawing.",subtext:"Radius: "+e+" m"}))}}),L.Draw.Marker=L.Draw.Feature.extend({statics:{TYPE:"marker"},options:{icon:new L.Icon.Default,zIndexOffset:2e3},initialize:function(t,e){this.type=L.Draw.Marker.TYPE,L.Draw.Feature.prototype.initialize.call(this,t,e)},addHooks:function(){L.Draw.Feature.prototype.addHooks.call(this),this._map&&(this._tooltip.updateContent({text:"Click map to place marker."}),this._mouseMarker||(this._mouseMarker=L.marker(this._map.getCenter(),{icon:L.divIcon({className:"leaflet-mouse-marker",iconAnchor:[20,20],iconSize:[40,40]}),opacity:0,zIndexOffset:this.options.zIndexOffset})),this._mouseMarker.on("click",this._onClick,this).addTo(this._map),this._map.on("mousemove",this._onMouseMove,this))},removeHooks:function(){L.Draw.Feature.prototype.removeHooks.call(this),this._map&&(this._marker&&(this._marker.off("click",this._onClick,this),this._map.off("click",this._onClick,this).removeLayer(this._marker),delete this._marker),this._mouseMarker.off("click",this._onClick,this),this._map.removeLayer(this._mouseMarker),delete this._mouseMarker,this._map.off("mousemove",this._onMouseMove,this))},_onMouseMove:function(t){var e=t.latlng;this._tooltip.updatePosition(e),this._mouseMarker.setLatLng(e),this._marker?this._marker.setLatLng(e):(this._marker=new L.Marker(e,{icon:this.options.icon,zIndexOffset:this.options.zIndexOffset}),this._marker.on("click",this._onClick,this),this._map.on("click",this._onClick,this).addLayer(this._marker))},_onClick:function(){this._fireCreatedEvent(),this.disable()},_fireCreatedEvent:function(){var t=new L.Marker(this._marker.getLatLng(),{icon:this.options.icon});L.Draw.Feature.prototype._fireCreatedEvent.call(this,t)}}),L.Edit=L.Edit||{},L.Edit.Poly=L.Handler.extend({options:{icon:new L.DivIcon({iconSize:new L.Point(8,8),className:"leaflet-div-icon leaflet-editing-icon"})},initialize:function(t,e){this._poly=t,L.setOptions(this,e)},addHooks:function(){this._poly._map&&(this._markerGroup||this._initMarkers(),this._poly._map.addLayer(this._markerGroup))},removeHooks:function(){this._poly._map&&(this._poly._map.removeLayer(this._markerGroup),delete this._markerGroup,delete this._markers)},updateMarkers:function(){this._markerGroup.clearLayers(),this._initMarkers()},_initMarkers:function(){this._markerGroup||(this._markerGroup=new L.LayerGroup),this._markers=[];var t,e,i,o,s=this._poly._latlngs;for(t=0,i=s.length;i>t;t++)o=this._createMarker(s[t],t),o.on("click",this._onMarkerClick,this),this._markers.push(o);var a,n;for(t=0,e=i-1;i>t;e=t++)(0!==t||L.Polygon&&this._poly instanceof L.Polygon)&&(a=this._markers[e],n=this._markers[t],this._createMiddleMarker(a,n),this._updatePrevNext(a,n))},_createMarker:function(t,e){var i=new L.Marker(t,{draggable:!0,icon:this.options.icon});return i._origLatLng=t,i._index=e,i.on("drag",this._onMarkerDrag,this),i.on("dragend",this._fireEdit,this),this._markerGroup.addLayer(i),i},_removeMarker:function(t){var e=t._index;this._markerGroup.removeLayer(t),this._markers.splice(e,1),this._poly.spliceLatLngs(e,1),this._updateIndexes(e,-1),t.off("drag",this._onMarkerDrag,this).off("dragend",this._fireEdit,this).off("click",this._onMarkerClick,this)},_fireEdit:function(){this._poly.edited=!0,this._poly.fire("edit")},_onMarkerDrag:function(t){var e=t.target;L.extend(e._origLatLng,e._latlng),e._middleLeft&&e._middleLeft.setLatLng(this._getMiddleLatLng(e._prev,e)),e._middleRight&&e._middleRight.setLatLng(this._getMiddleLatLng(e,e._next)),this._poly.redraw()},_onMarkerClick:function(t){if(!(3>this._poly._latlngs.length)){var e=t.target;this._removeMarker(e),this._updatePrevNext(e._prev,e._next),e._middleLeft&&this._markerGroup.removeLayer(e._middleLeft),e._middleRight&&this._markerGroup.removeLayer(e._middleRight),e._prev&&e._next?this._createMiddleMarker(e._prev,e._next):e._prev?e._next||(e._prev._middleRight=null):e._next._middleLeft=null,this._fireEdit()}},_updateIndexes:function(t,e){this._markerGroup.eachLayer(function(i){i._index>t&&(i._index+=e)})},_createMiddleMarker:function(t,e){var i,o,s,a=this._getMiddleLatLng(t,e),n=this._createMarker(a);n.setOpacity(.6),t._middleRight=e._middleLeft=n,o=function(){var o=e._index;n._index=o,n.off("click",i,this).on("click",this._onMarkerClick,this),a.lat=n.getLatLng().lat,a.lng=n.getLatLng().lng,this._poly.spliceLatLngs(o,0,a),this._markers.splice(o,0,n),n.setOpacity(1),this._updateIndexes(o,1),e._index++,this._updatePrevNext(t,n),this._updatePrevNext(n,e)},s=function(){n.off("dragstart",o,this),n.off("dragend",s,this),this._createMiddleMarker(t,n),this._createMiddleMarker(n,e)},i=function(){o.call(this),s.call(this),this._fireEdit()},n.on("click",i,this).on("dragstart",o,this).on("dragend",s,this),this._markerGroup.addLayer(n)},_updatePrevNext:function(t,e){t&&(t._next=e),e&&(e._prev=t)},_getMiddleLatLng:function(t,e){var i=this._poly._map,o=i.latLngToLayerPoint(t.getLatLng()),s=i.latLngToLayerPoint(e.getLatLng());return i.layerPointToLatLng(o._add(s)._divideBy(2))}}),L.Polyline.addInitHook(function(){this.editing||(L.Edit.Poly&&(this.editing=new L.Edit.Poly(this),this.options.editable&&this.editing.enable()),this.on("add",function(){this.editing&&this.editing.enabled()&&this.editing.addHooks()}),this.on("remove",function(){this.editing&&this.editing.enabled()&&this.editing.removeHooks()}))}),L.Edit=L.Edit||{},L.Edit.SimpleShape=L.Handler.extend({options:{moveIcon:new L.DivIcon({iconSize:new L.Point(8,8),className:"leaflet-div-icon leaflet-editing-icon leaflet-edit-move"}),resizeIcon:new L.DivIcon({iconSize:new L.Point(8,8),className:"leaflet-div-icon leaflet-editing-icon leaflet-edit-resize"})},initialize:function(t,e){this._shape=t,L.Util.setOptions(this,e)},addHooks:function(){this._shape._map&&(this._map=this._shape._map,this._markerGroup||this._initMarkers(),this._map.addLayer(this._markerGroup))},removeHooks:function(){if(this._shape._map){this._unbindMarker(this._moveMarker);for(var t=0,e=this._resizeMarkers.length;e>t;t++)this._unbindMarker(this._resizeMarkers[t]);this._resizeMarkers=null,this._map.removeLayer(this._markerGroup),delete this._markerGroup}this._map=null},updateMarkers:function(){this._markerGroup.clearLayers(),this._initMarkers()},_initMarkers:function(){this._markerGroup||(this._markerGroup=new L.LayerGroup),this._createMoveMarker(),this._createResizeMarker()},_createMoveMarker:function(){},_createResizeMarker:function(){},_createMarker:function(t,e){var i=new L.Marker(t,{draggable:!0,icon:e,zIndexOffset:10});return this._bindMarker(i),this._markerGroup.addLayer(i),i},_bindMarker:function(t){t.on("dragstart",this._onMarkerDragStart,this).on("drag",this._onMarkerDrag,this).on("dragend",this._onMarkerDragEnd,this)},_unbindMarker:function(t){t.off("dragstart",this._onMarkerDragStart,this).off("drag",this._onMarkerDrag,this).off("dragend",this._onMarkerDragEnd,this)},_onMarkerDragStart:function(t){var e=t.target;e.setOpacity(0)},_fireEdit:function(){this._shape.edited=!0,this._shape.fire("edit")},_onMarkerDrag:function(t){var e=t.target,i=e.getLatLng();e===this._moveMarker?this._move(i):this._resize(i),this._shape.redraw()},_onMarkerDragEnd:function(t){var e=t.target;e.setOpacity(1),this._shape.fire("edit"),this._fireEdit()},_move:function(){},_resize:function(){}}),L.Edit=L.Edit||{},L.Edit.Rectangle=L.Edit.SimpleShape.extend({_createMoveMarker:function(){var t=this._shape.getBounds(),e=t.getCenter();this._moveMarker=this._createMarker(e,this.options.moveIcon)},_createResizeMarker:function(){var t=this._getCorners();this._resizeMarkers=[];for(var e=0,i=t.length;i>e;e++)this._resizeMarkers.push(this._createMarker(t[e],this.options.resizeIcon)),this._resizeMarkers[e]._cornerIndex=e},_onMarkerDragStart:function(t){L.Edit.SimpleShape.prototype._onMarkerDragStart.call(this,t);var e=this._getCorners(),i=t.target,o=i._cornerIndex;this._oppositeCorner=e[(o+2)%4],this._toggleCornerMarkers(0,o)},_onMarkerDragEnd:function(t){var e,i,o=t.target;o===this._moveMarker&&(e=this._shape.getBounds(),i=e.getCenter(),o.setLatLng(i)),this._toggleCornerMarkers(1),this._repositionCornerMarkers(),L.Edit.SimpleShape.prototype._onMarkerDragEnd.call(this,t)},_move:function(t){for(var e,i=this._shape.getLatLngs(),o=this._shape.getBounds(),s=o.getCenter(),a=[],n=0,r=i.length;r>n;n++)e=[i[n].lat-s.lat,i[n].lng-s.lng],a.push([t.lat+e[0],t.lng+e[1]]);this._shape.setLatLngs(a),this._repositionCornerMarkers()},_resize:function(t){var e;this._shape.setBounds(L.latLngBounds(t,this._oppositeCorner)),e=this._shape.getBounds(),this._moveMarker.setLatLng(e.getCenter())},_getCorners:function(){var t=this._shape.getBounds(),e=t.getNorthWest(),i=t.getNorthEast(),o=t.getSouthEast(),s=t.getSouthWest();return[e,i,o,s]},_toggleCornerMarkers:function(t){for(var e=0,i=this._resizeMarkers.length;i>e;e++)this._resizeMarkers[e].setOpacity(t)},_repositionCornerMarkers:function(){for(var t=this._getCorners(),e=0,i=this._resizeMarkers.length;i>e;e++)this._resizeMarkers[e].setLatLng(t[e])}}),L.Rectangle.addInitHook(function(){L.Edit.Rectangle&&(this.editing=new L.Edit.Rectangle(this),this.options.editable&&this.editing.enable())}),L.Edit=L.Edit||{},L.Edit.Circle=L.Edit.SimpleShape.extend({_createMoveMarker:function(){var t=this._shape.getLatLng();this._moveMarker=this._createMarker(t,this.options.moveIcon)},_createResizeMarker:function(){var t=this._shape.getLatLng(),e=this._getResizeMarkerPoint(t);this._resizeMarkers=[],this._resizeMarkers.push(this._createMarker(e,this.options.resizeIcon))},_getResizeMarkerPoint:function(t){var e=this._shape._radius*Math.cos(Math.PI/4),i=this._map.project(t);return this._map.unproject([i.x+e,i.y-e])},_move:function(t){var e=this._getResizeMarkerPoint(t);this._resizeMarkers[0].setLatLng(e),this._shape.setLatLng(t)},_resize:function(t){var e=this._moveMarker.getLatLng(),i=e.distanceTo(t);this._shape.setRadius(i)}}),L.Circle.addInitHook(function(){L.Edit.Circle&&(this.editing=new L.Edit.Circle(this),this.options.editable&&this.editing.enable()),this.on("add",function(){this.editing&&this.editing.enabled()&&this.editing.addHooks()}),this.on("remove",function(){this.editing&&this.editing.enabled()&&this.editing.removeHooks()})}),L.LatLngUtil={cloneLatLngs:function(t){for(var e=[],i=0,o=t.length;o>i;i++)e.push(this.cloneLatLng(t[i]));return e},cloneLatLng:function(t){return L.latLng(t.lat,t.lng)}},L.Util.extend(L.LineUtil,{segmentsIntersect:function(t,e,i,o){return this._checkCounterclockwise(t,i,o)!==this._checkCounterclockwise(e,i,o)&&this._checkCounterclockwise(t,e,i)!==this._checkCounterclockwise(t,e,o)},_checkCounterclockwise:function(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}}),L.Polyline.include({intersects:function(){var t,e,i,o=this._originalPoints,s=o?o.length:0;if(this._tooFewPointsForIntersection())return!1;for(t=s-1;t>=3;t--)if(e=o[t-1],i=o[t],this._lineSegmentsIntersectsRange(e,i,t-2))return!0;return!1},newLatLngIntersects:function(t,e){return this._map?this.newPointIntersects(this._map.latLngToLayerPoint(t),e):!1},newPointIntersects:function(t,e){var i=this._originalPoints,o=i?i.length:0,s=i?i[o-1]:null,a=o-2;return this._tooFewPointsForIntersection(1)?!1:this._lineSegmentsIntersectsRange(s,t,a,e?1:0)},_tooFewPointsForIntersection:function(t){var e=this._originalPoints,i=e?e.length:0;return i+=t||0,!this._originalPoints||3>=i},_lineSegmentsIntersectsRange:function(t,e,i,o){var s,a,n=this._originalPoints;o=o||0;for(var r=i;r>o;r--)if(s=n[r-1],a=n[r],L.LineUtil.segmentsIntersect(t,e,s,a))return!0;return!1}}),L.Polygon.include({intersects:function(){var t,e,i,o,s,a=this._originalPoints;return this._tooFewPointsForIntersection()?!1:(t=L.Polyline.prototype.intersects.call(this))?!0:(e=a.length,i=a[0],o=a[e-1],s=e-2,this._lineSegmentsIntersectsRange(o,i,s,1))}}),L.Control.Draw=L.Control.extend({options:{position:"topleft",draw:{},edit:!1},initialize:function(t){if("0.5.1">=L.version)throw Error("Leaflet.draw 0.2.0+ requires Leaflet 0.6.0+. Download latest from https://github.com/Leaflet/Leaflet/");L.Control.prototype.initialize.call(this,t);var e,i;this._toolbars={},L.DrawToolbar&&this.options.draw&&(i=new L.DrawToolbar(this.options.draw),e=L.stamp(i),this._toolbars[e]=i,this._toolbars[e].on("enable",this._toolbarEnabled,this)),L.EditToolbar&&this.options.edit&&(i=new L.EditToolbar(this.options.edit),e=L.stamp(i),this._toolbars[e]=i,this._toolbars[e].on("enable",this._toolbarEnabled,this))},onAdd:function(t){var e,i=L.DomUtil.create("div","leaflet-draw"),o=!1,s="leaflet-draw-toolbar-top";for(var a in this._toolbars)this._toolbars.hasOwnProperty(a)&&(e=this._toolbars[a].addToolbar(t),o||(L.DomUtil.hasClass(e,s)||L.DomUtil.addClass(e.childNodes[0],s),o=!0),i.appendChild(e));return i},onRemove:function(){for(var t in this._toolbars)this._toolbars.hasOwnProperty(t)&&this._toolbars[t].removeToolbar()},setDrawingOptions:function(t){for(var e in this._toolbars)this._toolbars[e]instanceof L.DrawToolbar&&this._toolbars[e].setOptions(t)},_toolbarEnabled:function(t){var e=""+L.stamp(t.target);for(var i in this._toolbars)this._toolbars.hasOwnProperty(i)&&i!==e&&this._toolbars[i].disable()}}),L.Map.mergeOptions({drawControl:!1}),L.Map.addInitHook(function(){this.options.drawControl&&(this.drawControl=new L.Control.Draw,this.addControl(this.drawControl))}),L.Toolbar=L.Class.extend({includes:[L.Mixin.Events],initialize:function(t){L.setOptions(this,t),this._modes={},this._actionButtons=[],this._activeMode=null},enabled:function(){return null!==this._activeMode},disable:function(){this.enabled()&&this._activeMode.handler.disable()},removeToolbar:function(){for(var t in this._modes)this._modes.hasOwnProperty(t)&&(this._disposeButton(this._modes[t].button,this._modes[t].handler.enable),this._modes[t].handler.disable(),this._modes[t].handler.off("enabled",this._handlerActivated,this).off("disabled",this._handlerDeactivated,this));this._modes={};for(var e=0,i=this._actionButtons.length;i>e;e++)this._disposeButton(this._actionButtons[e].button,this._actionButtons[e].callback);this._actionButtons=[],this._actionsContainer=null},_initModeHandler:function(t,e,i,o){var s=t.type;this._modes[s]={},this._modes[s].handler=t,this._modes[s].button=this._createButton({title:this.options[s].title,className:o+"-"+s,container:e,callback:this._modes[s].handler.enable,context:this._modes[s].handler}),this._modes[s].buttonIndex=i,this._modes[s].handler.on("enabled",this._handlerActivated,this).on("disabled",this._handlerDeactivated,this)},_createButton:function(t){var e=L.DomUtil.create("a",t.className||"",t.container);return e.href="#",t.text&&(e.innerHTML=t.text),t.title&&(e.title=t.title),L.DomEvent.on(e,"click",L.DomEvent.stopPropagation).on(e,"mousedown",L.DomEvent.stopPropagation).on(e,"dblclick",L.DomEvent.stopPropagation).on(e,"click",L.DomEvent.preventDefault).on(e,"click",t.callback,t.context),e},_disposeButton:function(t,e){L.DomEvent.off(t,"click",L.DomEvent.stopPropagation).off(t,"mousedown",L.DomEvent.stopPropagation).off(t,"dblclick",L.DomEvent.stopPropagation).off(t,"click",L.DomEvent.preventDefault).off(t,"click",e)},_handlerActivated:function(t){this._activeMode&&this._activeMode.handler.enabled()&&this._activeMode.handler.disable(),this._activeMode=this._modes[t.handler],L.DomUtil.addClass(this._activeMode.button,"leaflet-draw-toolbar-button-enabled"),this._showActionsToolbar(),this.fire("enable")},_handlerDeactivated:function(){this._hideActionsToolbar(),L.DomUtil.removeClass(this._activeMode.button,"leaflet-draw-toolbar-button-enabled"),this._activeMode=null,this.fire("disable")},_createActions:function(t){for(var e,i,o=L.DomUtil.create("ul","leaflet-draw-actions"),s=50,a=t.length,n=a*s+(a-1),r=0;a>r;r++)e=L.DomUtil.create("li","",o),i=this._createButton({title:t[r].title,text:t[r].text,container:e,callback:t[r].callback,context:t[r].context}),this._actionButtons.push({button:i,callback:t[r].callback});return o.style.width=n+"px",o},_showActionsToolbar:function(){var t=this._activeMode.buttonIndex,e=this._lastButtonIndex,i=26,o=1,s=t*i+t*o-1;this._actionsContainer.style.top=s+"px",0===t&&(L.DomUtil.addClass(this._toolbarContainer,"leaflet-draw-toolbar-notop"),L.DomUtil.addClass(this._actionsContainer,"leaflet-draw-actions-top")),t===e&&(L.DomUtil.addClass(this._toolbarContainer,"leaflet-draw-toolbar-nobottom"),L.DomUtil.addClass(this._actionsContainer,"leaflet-draw-actions-bottom")),this._actionsContainer.style.display="block"},_hideActionsToolbar:function(){this._actionsContainer.style.display="none",L.DomUtil.removeClass(this._toolbarContainer,"leaflet-draw-toolbar-notop"),L.DomUtil.removeClass(this._toolbarContainer,"leaflet-draw-toolbar-nobottom"),L.DomUtil.removeClass(this._actionsContainer,"leaflet-draw-actions-top"),L.DomUtil.removeClass(this._actionsContainer,"leaflet-draw-actions-bottom")}}),L.Tooltip=L.Class.extend({initialize:function(t){this._map=t,this._popupPane=t._panes.popupPane,this._container=L.DomUtil.create("div","leaflet-draw-tooltip",this._popupPane),this._singleLineLabel=!1},dispose:function(){this._popupPane.removeChild(this._container),this._container=null},updateContent:function(t){return t.subtext=t.subtext||"",0!==t.subtext.length||this._singleLineLabel?t.subtext.length>0&&this._singleLineLabel&&(L.DomUtil.removeClass(this._container,"leaflet-draw-tooltip-single"),this._singleLineLabel=!1):(L.DomUtil.addClass(this._container,"leaflet-draw-tooltip-single"),this._singleLineLabel=!0),this._container.innerHTML=(t.subtext.length>0?'<span class="leaflet-draw-tooltip-subtext">'+t.subtext+"</span>"+"<br />":"")+"<span>"+t.text+"</span>",this},updatePosition:function(t){var e=this._map.latLngToLayerPoint(t);return L.DomUtil.setPosition(this._container,e),this},showAsError:function(){return L.DomUtil.addClass(this._container,"leaflet-error-draw-tooltip"),this},removeError:function(){return L.DomUtil.removeClass(this._container,"leaflet-error-draw-tooltip"),this}}),L.DrawToolbar=L.Toolbar.extend({options:{polyline:{title:"Draw a polyline"},polygon:{title:"Draw a polygon"},rectangle:{title:"Draw a rectangle"},circle:{title:"Draw a circle"},marker:{title:"Add a marker"}},initialize:function(t){L.Toolbar.prototype.initialize.call(this,t)},addToolbar:function(t){var e=L.DomUtil.create("div","leaflet-draw-section"),i=0,o="leaflet-draw-draw";return this._toolbarContainer=L.DomUtil.create("div","leaflet-draw-toolbar leaflet-bar"),this.options.polyline&&this._initModeHandler(new L.Draw.Polyline(t,this.options.polyline),this._toolbarContainer,i++,o),this.options.polygon&&this._initModeHandler(new L.Draw.Polygon(t,this.options.polygon),this._toolbarContainer,i++,o),this.options.rectangle&&this._initModeHandler(new L.Draw.Rectangle(t,this.options.rectangle),this._toolbarContainer,i++,o),this.options.circle&&this._initModeHandler(new L.Draw.Circle(t,this.options.circle),this._toolbarContainer,i++,o),this.options.marker&&this._initModeHandler(new L.Draw.Marker(t,this.options.marker),this._toolbarContainer,i++,o),this._lastButtonIndex=--i,this._actionsContainer=this._createActions([{title:"Cancel drawing",text:"Cancel",callback:this.disable,context:this}]),e.appendChild(this._toolbarContainer),e.appendChild(this._actionsContainer),e},setOptions:function(t){L.setOptions(this,t);for(var e in this._modes)this._modes.hasOwnProperty(e)&&t.hasOwnProperty(e)&&this._modes[e].handler.setOptions(t[e])}}),L.EditToolbar=L.Toolbar.extend({options:{edit:{title:"Edit layers",selectedPathOptions:null},remove:{title:"Delete layers"},featureGroup:null},initialize:function(t){L.Toolbar.prototype.initialize.call(this,t),this._selectedFeatureCount=0},addToolbar:function(t){var e=L.DomUtil.create("div","leaflet-draw-section"),i=0,o="leaflet-draw-edit";return this._toolbarContainer=L.DomUtil.create("div","leaflet-draw-toolbar leaflet-bar"),this._map=t,this.options.edit&&this._initModeHandler(new L.EditToolbar.Edit(t,{featureGroup:this.options.featureGroup,selectedPathOptions:this.options.edit.selectedPathOptions}),this._toolbarContainer,i++,o),this.options.remove&&this._initModeHandler(new L.EditToolbar.Delete(t,{featureGroup:this.options.featureGroup}),this._toolbarContainer,i++,o),this._lastButtonIndex=--i,this._actionsContainer=this._createActions([{title:"Save changes.",text:"Save",callback:this._save,context:this},{title:"Cancel editing, discards all changes.",text:"Cancel",callback:this.disable,context:this}]),e.appendChild(this._toolbarContainer),e.appendChild(this._actionsContainer),e},disable:function(){this.enabled()&&(this._activeMode.handler.revertLayers(),L.Toolbar.prototype.disable.call(this))},_save:function(){this._activeMode.handler.save(),this._activeMode.handler.disable()}}),L.EditToolbar.Edit=L.Handler.extend({statics:{TYPE:"edit"},includes:L.Mixin.Events,options:{selectedPathOptions:{color:"#fe57a1",opacity:.6,dashArray:"10, 10",fill:!0,fillColor:"#fe57a1",fillOpacity:.1}},initialize:function(t,e){if(L.Handler.prototype.initialize.call(this,t),e.selectedPathOptions=e.selectedPathOptions||this.options.selectedPathOptions,L.Util.setOptions(this,e),this._featureGroup=this.options.featureGroup,!(this._featureGroup instanceof L.FeatureGroup))throw Error("options.featureGroup must be a L.FeatureGroup");
|
10
|
+
this._uneditedLayerProps={},this.type=L.EditToolbar.Edit.TYPE},enable:function(){this._enabled||(L.Handler.prototype.enable.call(this),this._featureGroup.on("layeradd",this._enableLayerEdit,this).on("layerremove",this._disableLayerEdit,this),this.fire("enabled",{handler:this.type}))},disable:function(){this._enabled&&(this.fire("disabled",{handler:this.type}),this._featureGroup.off("layeradd",this._enableLayerEdit,this).off("layerremove",this._disableLayerEdit,this),L.Handler.prototype.disable.call(this))},addHooks:function(){this._map&&(this._featureGroup.eachLayer(this._enableLayerEdit,this),this._tooltip=new L.Tooltip(this._map),this._tooltip.updateContent({text:"Drag handles, or marker to edit feature.",subtext:"Click cancel to undo changes."}),this._map.on("mousemove",this._onMouseMove,this))},removeHooks:function(){this._map&&(this._featureGroup.eachLayer(this._disableLayerEdit,this),this._uneditedLayerProps={},this._tooltip.dispose(),this._tooltip=null,this._map.off("mousemove",this._onMouseMove,this))},revertLayers:function(){this._featureGroup.eachLayer(function(t){this._revertLayer(t)},this)},save:function(){var t=new L.LayerGroup;this._featureGroup.eachLayer(function(e){e.edited&&(t.addLayer(e),e.edited=!1)}),this._map.fire("draw:edited",{layers:t})},_backupLayer:function(t){var e=L.Util.stamp(t);this._uneditedLayerProps[e]||(this._uneditedLayerProps[e]=t instanceof L.Polyline||t instanceof L.Polygon||t instanceof L.Rectangle?{latlngs:L.LatLngUtil.cloneLatLngs(t.getLatLngs())}:t instanceof L.Circle?{latlng:L.LatLngUtil.cloneLatLng(t.getLatLng()),radius:t.getRadius()}:{latlng:L.LatLngUtil.cloneLatLng(t.getLatLng())})},_revertLayer:function(t){var e=L.Util.stamp(t);t.edited=!1,this._uneditedLayerProps.hasOwnProperty(e)&&(t instanceof L.Polyline||t instanceof L.Polygon||t instanceof L.Rectangle?t.setLatLngs(this._uneditedLayerProps[e].latlngs):t instanceof L.Circle?(t.setLatLng(this._uneditedLayerProps[e].latlng),t.setRadius(this._uneditedLayerProps[e].radius)):t.setLatLng(this._uneditedLayerProps[e].latlng))},_toggleMarkerHighlight:function(t){var e=t._icon;e.style.display="none",L.DomUtil.hasClass(e,"leaflet-edit-marker-selected")?(L.DomUtil.removeClass(e,"leaflet-edit-marker-selected"),this._offsetMarker(e,-4)):(L.DomUtil.addClass(e,"leaflet-edit-marker-selected"),this._offsetMarker(e,4)),e.style.display=""},_offsetMarker:function(t,e){var i=parseInt(t.style.marginTop,10)-e,o=parseInt(t.style.marginLeft,10)-e;t.style.marginTop=i+"px",t.style.marginLeft=o+"px"},_enableLayerEdit:function(t){var e=t.layer||t.target||t,i=L.Util.extend({},this.options.selectedPathOptions);this._backupLayer(e),e instanceof L.Marker?this._toggleMarkerHighlight(e):(e.options.previousOptions=e.options,e instanceof L.Circle||e instanceof L.Polygon||e instanceof L.Rectangle||(i.fill=!1),e.setStyle(i)),e instanceof L.Marker?(e.dragging.enable(),e.on("dragend",this._onMarkerDragEnd)):e.editing.enable()},_disableLayerEdit:function(t){var e=t.layer||t.target||t;e.edited=!1,e instanceof L.Marker?this._toggleMarkerHighlight(e):(e.setStyle(e.options.previousOptions),delete e.options.previousOptions),e instanceof L.Marker?(e.dragging.disable(),e.off("dragend",this._onMarkerDragEnd,this)):e.editing.disable()},_onMarkerDragEnd:function(t){var e=t.target;e.edited=!0},_onMouseMove:function(t){this._tooltip.updatePosition(t.latlng)}}),L.EditToolbar.Delete=L.Handler.extend({statics:{TYPE:"remove"},includes:L.Mixin.Events,initialize:function(t,e){if(L.Handler.prototype.initialize.call(this,t),L.Util.setOptions(this,e),this._deletableLayers=this.options.featureGroup,!(this._deletableLayers instanceof L.FeatureGroup))throw Error("options.featureGroup must be a L.FeatureGroup");this.type=L.EditToolbar.Delete.TYPE},enable:function(){this._enabled||(L.Handler.prototype.enable.call(this),this._deletableLayers.on("layeradd",this._enableLayerDelete,this).on("layerremove",this._disableLayerDelete,this),this.fire("enabled",{handler:this.type}))},disable:function(){this._enabled&&(L.Handler.prototype.disable.call(this),this._deletableLayers.off("layeradd",this._enableLayerDelete,this).off("layerremove",this._disableLayerDelete,this),this.fire("disabled",{handler:this.type}))},addHooks:function(){this._map&&(this._deletableLayers.eachLayer(this._enableLayerDelete,this),this._deletedLayers=new L.layerGroup,this._tooltip=new L.Tooltip(this._map),this._tooltip.updateContent({text:"Click on a feature to remove."}),this._map.on("mousemove",this._onMouseMove,this))},removeHooks:function(){this._map&&(this._deletableLayers.eachLayer(this._disableLayerDelete,this),this._deletedLayers=null,this._tooltip.dispose(),this._tooltip=null,this._map.off("mousemove",this._onMouseMove,this))},revertLayers:function(){this._deletedLayers.eachLayer(function(t){this._deletableLayers.addLayer(t)},this)},save:function(){this._map.fire("draw:deleted",{layers:this._deletedLayers})},_enableLayerDelete:function(t){var e=t.layer||t.target||t;e.on("click",this._removeLayer,this)},_disableLayerDelete:function(t){var e=t.layer||t.target||t;e.off("click",this._removeLayer,this),this._deletedLayers.removeLayer(e)},_removeLayer:function(t){var e=t.layer||t.target||t;this._deletableLayers.removeLayer(e),this._deletedLayers.addLayer(e)},_onMouseMove:function(t){this._tooltip.updatePosition(t.latlng)}})})(this,document);
|
@@ -0,0 +1,106 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Leaflet.draw drawing and editing tools</title>
|
5
|
+
|
6
|
+
<link rel="stylesheet" href="libs/leaflet.css" />
|
7
|
+
<!--[if lte IE 8]><link rel="stylesheet" href="libs/leaflet.ie.css" /><![endif]-->
|
8
|
+
<link rel="stylesheet" href="../dist/leaflet.draw.css" />
|
9
|
+
<!--[if lte IE 8]><link rel="stylesheet" href="../dist/leaflet.draw.ie.css" /><![endif]-->
|
10
|
+
|
11
|
+
<script src="libs/leaflet-src.js"></script>
|
12
|
+
|
13
|
+
<script src="../src/Leaflet.draw.js"></script>
|
14
|
+
|
15
|
+
<script src="../src/edit/handler/Edit.Poly.js"></script>
|
16
|
+
<script src="../src/edit/handler/Edit.SimpleShape.js"></script>
|
17
|
+
<script src="../src/edit/handler/Edit.Circle.js"></script>
|
18
|
+
<script src="../src/edit/handler/Edit.Rectangle.js"></script>
|
19
|
+
|
20
|
+
<script src="../src/draw/handler/Draw.Feature.js"></script>
|
21
|
+
<script src="../src/draw/handler/Draw.Polyline.js"></script>
|
22
|
+
<script src="../src/draw/handler/Draw.Polygon.js"></script>
|
23
|
+
<script src="../src/draw/handler/Draw.SimpleShape.js"></script>
|
24
|
+
<script src="../src/draw/handler/Draw.Rectangle.js"></script>
|
25
|
+
<script src="../src/draw/handler/Draw.Circle.js"></script>
|
26
|
+
<script src="../src/draw/handler/Draw.Marker.js"></script>
|
27
|
+
|
28
|
+
<script src="../src/ext/LatLngUtil.js"></script>
|
29
|
+
<script src="../src/ext/LineUtil.Intersect.js"></script>
|
30
|
+
<script src="../src/ext/Polygon.Intersect.js"></script>
|
31
|
+
<script src="../src/ext/Polyline.Intersect.js"></script>
|
32
|
+
|
33
|
+
<script src="../src/Control.Draw.js"></script>
|
34
|
+
<script src="../src/Tooltip.js"></script>
|
35
|
+
<script src="../src/Toolbar.js"></script>
|
36
|
+
|
37
|
+
<script src="../src/draw/DrawToolbar.js"></script>
|
38
|
+
<script src="../src/edit/EditToolbar.js"></script>
|
39
|
+
<script src="../src/edit/handler/EditToolbar.Edit.js"></script>
|
40
|
+
<script src="../src/edit/handler/EditToolbar.Delete.js"></script>
|
41
|
+
</head>
|
42
|
+
<body>
|
43
|
+
<div id="map" style="width: 800px; height: 600px; border: 1px solid #ccc"></div>
|
44
|
+
<button id="changeColor">Rectangle -> Blue</button>
|
45
|
+
<script>
|
46
|
+
|
47
|
+
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png',
|
48
|
+
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18}),
|
49
|
+
map = new L.Map('map', {layers: [cloudmade], center: new L.LatLng(-37.7772, 175.2756), zoom: 15 });
|
50
|
+
|
51
|
+
var drawnItems = new L.FeatureGroup();
|
52
|
+
map.addLayer(drawnItems);
|
53
|
+
|
54
|
+
var drawControl = new L.Control.Draw({
|
55
|
+
draw: {
|
56
|
+
position: 'topleft',
|
57
|
+
polygon: {
|
58
|
+
title: 'Draw a sexy polygon!',
|
59
|
+
allowIntersection: false,
|
60
|
+
drawError: {
|
61
|
+
color: '#b00b00',
|
62
|
+
timeout: 1000
|
63
|
+
},
|
64
|
+
shapeOptions: {
|
65
|
+
color: '#bada55'
|
66
|
+
}
|
67
|
+
},
|
68
|
+
circle: {
|
69
|
+
shapeOptions: {
|
70
|
+
color: '#662d91'
|
71
|
+
}
|
72
|
+
}
|
73
|
+
},
|
74
|
+
edit: {
|
75
|
+
featureGroup: drawnItems
|
76
|
+
}
|
77
|
+
});
|
78
|
+
map.addControl(drawControl);
|
79
|
+
|
80
|
+
map.on('draw:created', function (e) {
|
81
|
+
var type = e.layerType,
|
82
|
+
layer = e.layer;
|
83
|
+
|
84
|
+
if (type === 'marker') {
|
85
|
+
layer.bindPopup('A popup!');
|
86
|
+
}
|
87
|
+
|
88
|
+
drawnItems.addLayer(layer);
|
89
|
+
});
|
90
|
+
|
91
|
+
map.on('draw:edited', function (e) {
|
92
|
+
var layers = e.layers;
|
93
|
+
var countOfEditedLayers = 0;
|
94
|
+
layers.eachLayer(function(layer) {
|
95
|
+
countOfEditedLayers++;
|
96
|
+
});
|
97
|
+
console.log("Edited " + countOfEditedLayers + " layers");
|
98
|
+
});
|
99
|
+
|
100
|
+
L.DomUtil.get('changeColor').onclick = function () {
|
101
|
+
drawControl.setDrawingOptions({ rectangle: { shapeOptions: { color: '#004a80' } } });
|
102
|
+
};
|
103
|
+
|
104
|
+
</script>
|
105
|
+
</body>
|
106
|
+
</html>
|
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Leaflet.draw vector editing handlers</title>
|
5
|
+
|
6
|
+
<link rel="stylesheet" href="libs/leaflet.css" />
|
7
|
+
<!--[if lte IE 8]><link rel="stylesheet" href="libs/leaflet.ie.css" /><![endif]-->
|
8
|
+
|
9
|
+
<script src="libs/leaflet-src.js"></script>
|
10
|
+
|
11
|
+
<script src="../src/Leaflet.draw.js"></script>
|
12
|
+
|
13
|
+
<script src="../src/edit/handler/Edit.Poly.js"></script>
|
14
|
+
<script src="../src/edit/handler/Edit.SimpleShape.js"></script>
|
15
|
+
<script src="../src/edit/handler/Edit.Circle.js"></script>
|
16
|
+
<script src="../src/edit/handler/Edit.Rectangle.js"></script>
|
17
|
+
</head>
|
18
|
+
<body>
|
19
|
+
<div id="map" style="width: 800px; height: 600px; border: 1px solid #ccc"></div>
|
20
|
+
|
21
|
+
<script>
|
22
|
+
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png',
|
23
|
+
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18}),
|
24
|
+
map = new L.Map('map', {layers: [cloudmade], center: new L.LatLng(51.505, -0.04), zoom: 13});
|
25
|
+
|
26
|
+
var polygon = new L.Polygon([
|
27
|
+
[51.51, -0.1],
|
28
|
+
[51.5, -0.06],
|
29
|
+
[51.52, -0.03]
|
30
|
+
]);
|
31
|
+
|
32
|
+
polygon.editing.enable();
|
33
|
+
|
34
|
+
map.addLayer(polygon);
|
35
|
+
|
36
|
+
var polyline = new L.Polyline([
|
37
|
+
[51.50, -0.04],
|
38
|
+
[51.49, -0.02],
|
39
|
+
[51.51, 0],
|
40
|
+
[51.52, -0.02]
|
41
|
+
]);
|
42
|
+
|
43
|
+
polyline.editing.enable();
|
44
|
+
|
45
|
+
map.addLayer(polyline);
|
46
|
+
|
47
|
+
var circle = L.circle([51.53, -0.06], 600);
|
48
|
+
|
49
|
+
circle.editing.enable();
|
50
|
+
|
51
|
+
map.addLayer(circle);
|
52
|
+
|
53
|
+
var rectangle = L.rectangle([[51.49, -0.1], [51.48, -0.06]]);
|
54
|
+
|
55
|
+
rectangle.editing.enable();
|
56
|
+
|
57
|
+
map.addLayer(rectangle);
|
58
|
+
|
59
|
+
polygon.on('edit', function() {
|
60
|
+
console.log('Polygon was edited!');
|
61
|
+
});
|
62
|
+
polyline.on('edit', function() {
|
63
|
+
console.log('Polyline was edited!');
|
64
|
+
});
|
65
|
+
</script>
|
66
|
+
</body>
|
67
|
+
</html>
|
Binary file
|
Binary file
|
Binary file
|