leaflet-js 0.6.beta4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,59 @@
|
|
1
|
+
L.Draw.Circle = L.Draw.SimpleShape.extend({
|
2
|
+
statics: {
|
3
|
+
TYPE: 'circle'
|
4
|
+
},
|
5
|
+
|
6
|
+
options: {
|
7
|
+
shapeOptions: {
|
8
|
+
stroke: true,
|
9
|
+
color: '#f06eaa',
|
10
|
+
weight: 4,
|
11
|
+
opacity: 0.5,
|
12
|
+
fill: true,
|
13
|
+
fillColor: null, //same as color by default
|
14
|
+
fillOpacity: 0.2,
|
15
|
+
clickable: true
|
16
|
+
}
|
17
|
+
},
|
18
|
+
|
19
|
+
initialize: function (map, options) {
|
20
|
+
// Save the type so super can fire, need to do this as cannot do this.TYPE :(
|
21
|
+
this.type = L.Draw.Circle.TYPE;
|
22
|
+
|
23
|
+
L.Draw.SimpleShape.prototype.initialize.call(this, map, options);
|
24
|
+
},
|
25
|
+
|
26
|
+
_initialLabelText: 'Click and drag to draw circle.',
|
27
|
+
|
28
|
+
_drawShape: function (latlng) {
|
29
|
+
if (!this._shape) {
|
30
|
+
this._shape = new L.Circle(this._startLatLng, this._startLatLng.distanceTo(latlng), this.options.shapeOptions);
|
31
|
+
this._map.addLayer(this._shape);
|
32
|
+
} else {
|
33
|
+
this._shape.setRadius(this._startLatLng.distanceTo(latlng));
|
34
|
+
}
|
35
|
+
},
|
36
|
+
|
37
|
+
_fireCreatedEvent: function () {
|
38
|
+
var circle = new L.Circle(this._startLatLng, this._shape.getRadius(), this.options.shapeOptions);
|
39
|
+
L.Draw.SimpleShape.prototype._fireCreatedEvent.call(this, circle);
|
40
|
+
},
|
41
|
+
|
42
|
+
_onMouseMove: function (e) {
|
43
|
+
var latlng = e.latlng,
|
44
|
+
radius;
|
45
|
+
|
46
|
+
this._tooltip.updatePosition(latlng);
|
47
|
+
if (this._isDrawing) {
|
48
|
+
this._drawShape(latlng);
|
49
|
+
|
50
|
+
// Get the new radius (rouded to 1 dp)
|
51
|
+
radius = this._shape.getRadius().toFixed(1);
|
52
|
+
|
53
|
+
this._tooltip.updateContent({
|
54
|
+
text: 'Release mouse to finish drawing.',
|
55
|
+
subtext: 'Radius: ' + radius + ' m'
|
56
|
+
});
|
57
|
+
}
|
58
|
+
}
|
59
|
+
});
|
@@ -0,0 +1,74 @@
|
|
1
|
+
L.Draw = {};
|
2
|
+
|
3
|
+
L.Draw.Feature = L.Handler.extend({
|
4
|
+
includes: L.Mixin.Events,
|
5
|
+
|
6
|
+
initialize: function (map, options) {
|
7
|
+
this._map = map;
|
8
|
+
this._container = map._container;
|
9
|
+
this._overlayPane = map._panes.overlayPane;
|
10
|
+
this._popupPane = map._panes.popupPane;
|
11
|
+
|
12
|
+
// Merge default shapeOptions options with custom shapeOptions
|
13
|
+
if (options && options.shapeOptions) {
|
14
|
+
options.shapeOptions = L.Util.extend({}, this.options.shapeOptions, options.shapeOptions);
|
15
|
+
}
|
16
|
+
L.Util.extend(this.options, options);
|
17
|
+
},
|
18
|
+
|
19
|
+
enable: function () {
|
20
|
+
if (this._enabled) { return; }
|
21
|
+
|
22
|
+
L.Handler.prototype.enable.call(this);
|
23
|
+
|
24
|
+
this.fire('enabled', { handler: this.type });
|
25
|
+
|
26
|
+
this._map.fire('draw:drawstart', { layerType: this.type });
|
27
|
+
},
|
28
|
+
|
29
|
+
disable: function () {
|
30
|
+
if (!this._enabled) { return; }
|
31
|
+
|
32
|
+
L.Handler.prototype.disable.call(this);
|
33
|
+
|
34
|
+
this.fire('disabled', { handler: this.type });
|
35
|
+
|
36
|
+
this._map.fire('draw:drawstop', { layerType: this.type });
|
37
|
+
},
|
38
|
+
|
39
|
+
addHooks: function () {
|
40
|
+
if (this._map) {
|
41
|
+
L.DomUtil.disableTextSelection();
|
42
|
+
|
43
|
+
this._tooltip = new L.Tooltip(this._map);
|
44
|
+
|
45
|
+
L.DomEvent.addListener(this._container, 'keyup', this._cancelDrawing, this);
|
46
|
+
}
|
47
|
+
},
|
48
|
+
|
49
|
+
removeHooks: function () {
|
50
|
+
if (this._map) {
|
51
|
+
L.DomUtil.enableTextSelection();
|
52
|
+
|
53
|
+
this._tooltip.dispose();
|
54
|
+
this._tooltip = null;
|
55
|
+
|
56
|
+
L.DomEvent.removeListener(this._container, 'keyup', this._cancelDrawing);
|
57
|
+
}
|
58
|
+
},
|
59
|
+
|
60
|
+
setOptions: function (options) {
|
61
|
+
L.setOptions(this, options);
|
62
|
+
},
|
63
|
+
|
64
|
+
_fireCreatedEvent: function (layer) {
|
65
|
+
this._map.fire('draw:created', { layer: layer, layerType: this.type });
|
66
|
+
},
|
67
|
+
|
68
|
+
// Cancel drawing when the escape key is pressed
|
69
|
+
_cancelDrawing: function (e) {
|
70
|
+
if (e.keyCode === 27) {
|
71
|
+
this.disable();
|
72
|
+
}
|
73
|
+
}
|
74
|
+
});
|
@@ -0,0 +1,97 @@
|
|
1
|
+
L.Draw.Marker = L.Draw.Feature.extend({
|
2
|
+
statics: {
|
3
|
+
TYPE: 'marker'
|
4
|
+
},
|
5
|
+
|
6
|
+
options: {
|
7
|
+
icon: new L.Icon.Default(),
|
8
|
+
zIndexOffset: 2000 // This should be > than the highest z-index any markers
|
9
|
+
},
|
10
|
+
|
11
|
+
initialize: function (map, options) {
|
12
|
+
// Save the type so super can fire, need to do this as cannot do this.TYPE :(
|
13
|
+
this.type = L.Draw.Marker.TYPE;
|
14
|
+
|
15
|
+
L.Draw.Feature.prototype.initialize.call(this, map, options);
|
16
|
+
},
|
17
|
+
|
18
|
+
addHooks: function () {
|
19
|
+
L.Draw.Feature.prototype.addHooks.call(this);
|
20
|
+
|
21
|
+
if (this._map) {
|
22
|
+
this._tooltip.updateContent({ text: 'Click map to place marker.' });
|
23
|
+
|
24
|
+
// Same mouseMarker as in Draw.Polyline
|
25
|
+
if (!this._mouseMarker) {
|
26
|
+
this._mouseMarker = L.marker(this._map.getCenter(), {
|
27
|
+
icon: L.divIcon({
|
28
|
+
className: 'leaflet-mouse-marker',
|
29
|
+
iconAnchor: [20, 20],
|
30
|
+
iconSize: [40, 40]
|
31
|
+
}),
|
32
|
+
opacity: 0,
|
33
|
+
zIndexOffset: this.options.zIndexOffset
|
34
|
+
});
|
35
|
+
}
|
36
|
+
|
37
|
+
this._mouseMarker
|
38
|
+
.on('click', this._onClick, this)
|
39
|
+
.addTo(this._map);
|
40
|
+
|
41
|
+
this._map.on('mousemove', this._onMouseMove, this);
|
42
|
+
}
|
43
|
+
},
|
44
|
+
|
45
|
+
removeHooks: function () {
|
46
|
+
L.Draw.Feature.prototype.removeHooks.call(this);
|
47
|
+
|
48
|
+
if (this._map) {
|
49
|
+
if (this._marker) {
|
50
|
+
this._marker.off('click', this._onClick, this);
|
51
|
+
this._map
|
52
|
+
.off('click', this._onClick, this)
|
53
|
+
.removeLayer(this._marker);
|
54
|
+
delete this._marker;
|
55
|
+
}
|
56
|
+
|
57
|
+
this._mouseMarker.off('click', this._onClick, this);
|
58
|
+
this._map.removeLayer(this._mouseMarker);
|
59
|
+
delete this._mouseMarker;
|
60
|
+
|
61
|
+
this._map.off('mousemove', this._onMouseMove, this);
|
62
|
+
}
|
63
|
+
},
|
64
|
+
|
65
|
+
_onMouseMove: function (e) {
|
66
|
+
var latlng = e.latlng;
|
67
|
+
|
68
|
+
this._tooltip.updatePosition(latlng);
|
69
|
+
this._mouseMarker.setLatLng(latlng);
|
70
|
+
|
71
|
+
if (!this._marker) {
|
72
|
+
this._marker = new L.Marker(latlng, {
|
73
|
+
icon: this.options.icon,
|
74
|
+
zIndexOffset: this.options.zIndexOffset
|
75
|
+
});
|
76
|
+
// Bind to both marker and map to make sure we get the click event.
|
77
|
+
this._marker.on('click', this._onClick, this);
|
78
|
+
this._map
|
79
|
+
.on('click', this._onClick, this)
|
80
|
+
.addLayer(this._marker);
|
81
|
+
}
|
82
|
+
else {
|
83
|
+
this._marker.setLatLng(latlng);
|
84
|
+
}
|
85
|
+
},
|
86
|
+
|
87
|
+
_onClick: function () {
|
88
|
+
this._fireCreatedEvent();
|
89
|
+
|
90
|
+
this.disable();
|
91
|
+
},
|
92
|
+
|
93
|
+
_fireCreatedEvent: function () {
|
94
|
+
var marker = new L.Marker(this._marker.getLatLng(), { icon: this.options.icon });
|
95
|
+
L.Draw.Feature.prototype._fireCreatedEvent.call(this, marker);
|
96
|
+
}
|
97
|
+
});
|
@@ -0,0 +1,79 @@
|
|
1
|
+
L.Draw.Polygon = L.Draw.Polyline.extend({
|
2
|
+
statics: {
|
3
|
+
TYPE: 'polygon'
|
4
|
+
},
|
5
|
+
|
6
|
+
Poly: L.Polygon,
|
7
|
+
|
8
|
+
options: {
|
9
|
+
shapeOptions: {
|
10
|
+
stroke: true,
|
11
|
+
color: '#f06eaa',
|
12
|
+
weight: 4,
|
13
|
+
opacity: 0.5,
|
14
|
+
fill: true,
|
15
|
+
fillColor: null, //same as color by default
|
16
|
+
fillOpacity: 0.2,
|
17
|
+
clickable: true
|
18
|
+
}
|
19
|
+
},
|
20
|
+
|
21
|
+
initialize: function (map, options) {
|
22
|
+
L.Draw.Polyline.prototype.initialize.call(this, map, options);
|
23
|
+
|
24
|
+
// Save the type so super can fire, need to do this as cannot do this.TYPE :(
|
25
|
+
this.type = L.Draw.Polygon.TYPE;
|
26
|
+
},
|
27
|
+
|
28
|
+
_updateFinishHandler: function () {
|
29
|
+
var markerCount = this._markers.length;
|
30
|
+
|
31
|
+
// The first marker shold have a click handler to close the polygon
|
32
|
+
if (markerCount === 1) {
|
33
|
+
this._markers[0].on('click', this._finishShape, this);
|
34
|
+
}
|
35
|
+
|
36
|
+
// Add and update the double click handler
|
37
|
+
if (markerCount > 2) {
|
38
|
+
this._markers[markerCount - 1].on('dblclick', this._finishShape, this);
|
39
|
+
// Only need to remove handler if has been added before
|
40
|
+
if (markerCount > 3) {
|
41
|
+
this._markers[markerCount - 2].off('dblclick', this._finishShape, this);
|
42
|
+
}
|
43
|
+
}
|
44
|
+
},
|
45
|
+
|
46
|
+
_getTooltipText: function () {
|
47
|
+
var text;
|
48
|
+
if (this._markers.length === 0) {
|
49
|
+
text = 'Click to start drawing shape.';
|
50
|
+
} else if (this._markers.length < 3) {
|
51
|
+
text = 'Click to continue drawing shape.';
|
52
|
+
} else {
|
53
|
+
text = 'Double click to close this shape.';
|
54
|
+
}
|
55
|
+
return {
|
56
|
+
text: text
|
57
|
+
};
|
58
|
+
},
|
59
|
+
|
60
|
+
_shapeIsValid: function () {
|
61
|
+
return this._markers.length >= 3;
|
62
|
+
},
|
63
|
+
|
64
|
+
_vertexAdded: function () {
|
65
|
+
//calc area here
|
66
|
+
},
|
67
|
+
|
68
|
+
_cleanUpShape: function () {
|
69
|
+
var markerCount = this._markers.length;
|
70
|
+
|
71
|
+
if (markerCount > 0) {
|
72
|
+
this._markers[0].off('click', this._finishShape, this);
|
73
|
+
|
74
|
+
if (markerCount > 2) {
|
75
|
+
this._markers[markerCount - 1].off('dblclick', this._finishShape, this);
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}
|
79
|
+
});
|
@@ -0,0 +1,360 @@
|
|
1
|
+
L.Draw.Polyline = L.Draw.Feature.extend({
|
2
|
+
statics: {
|
3
|
+
TYPE: 'polyline'
|
4
|
+
},
|
5
|
+
|
6
|
+
Poly: L.Polyline,
|
7
|
+
|
8
|
+
options: {
|
9
|
+
allowIntersection: true,
|
10
|
+
drawError: {
|
11
|
+
color: '#b00b00',
|
12
|
+
message: '<strong>Error:</strong> shape edges cannot cross!',
|
13
|
+
timeout: 2500
|
14
|
+
},
|
15
|
+
icon: new L.DivIcon({
|
16
|
+
iconSize: new L.Point(8, 8),
|
17
|
+
className: 'leaflet-div-icon leaflet-editing-icon'
|
18
|
+
}),
|
19
|
+
guidelineDistance: 20,
|
20
|
+
shapeOptions: {
|
21
|
+
stroke: true,
|
22
|
+
color: '#f06eaa',
|
23
|
+
weight: 4,
|
24
|
+
opacity: 0.5,
|
25
|
+
fill: false,
|
26
|
+
clickable: true
|
27
|
+
},
|
28
|
+
zIndexOffset: 2000 // This should be > than the highest z-index any map layers
|
29
|
+
},
|
30
|
+
|
31
|
+
initialize: function (map, options) {
|
32
|
+
// Merge default drawError options with custom options
|
33
|
+
if (options && options.drawError) {
|
34
|
+
options.drawError = L.Util.extend({}, this.options.drawError, options.drawError);
|
35
|
+
}
|
36
|
+
|
37
|
+
// Save the type so super can fire, need to do this as cannot do this.TYPE :(
|
38
|
+
this.type = L.Draw.Polyline.TYPE;
|
39
|
+
|
40
|
+
L.Draw.Feature.prototype.initialize.call(this, map, options);
|
41
|
+
},
|
42
|
+
|
43
|
+
addHooks: function () {
|
44
|
+
L.Draw.Feature.prototype.addHooks.call(this);
|
45
|
+
if (this._map) {
|
46
|
+
this._markers = [];
|
47
|
+
|
48
|
+
this._markerGroup = new L.LayerGroup();
|
49
|
+
this._map.addLayer(this._markerGroup);
|
50
|
+
|
51
|
+
this._poly = new L.Polyline([], this.options.shapeOptions);
|
52
|
+
|
53
|
+
this._tooltip.updateContent(this._getTooltipText());
|
54
|
+
|
55
|
+
// Make a transparent marker that will used to catch click events. These click
|
56
|
+
// events will create the vertices. We need to do this so we can ensure that
|
57
|
+
// we can create vertices over other map layers (markers, vector layers). We
|
58
|
+
// also do not want to trigger any click handlers of objects we are clicking on
|
59
|
+
// while drawing.
|
60
|
+
if (!this._mouseMarker) {
|
61
|
+
this._mouseMarker = L.marker(this._map.getCenter(), {
|
62
|
+
icon: L.divIcon({
|
63
|
+
className: 'leaflet-mouse-marker',
|
64
|
+
iconAnchor: [20, 20],
|
65
|
+
iconSize: [40, 40]
|
66
|
+
}),
|
67
|
+
opacity: 0,
|
68
|
+
zIndexOffset: this.options.zIndexOffset
|
69
|
+
});
|
70
|
+
}
|
71
|
+
|
72
|
+
this._mouseMarker
|
73
|
+
.on('click', this._onClick, this)
|
74
|
+
.addTo(this._map);
|
75
|
+
|
76
|
+
this._map
|
77
|
+
.on('mousemove', this._onMouseMove, this)
|
78
|
+
.on('zoomend', this._onZoomEnd, this);
|
79
|
+
}
|
80
|
+
},
|
81
|
+
|
82
|
+
removeHooks: function () {
|
83
|
+
L.Draw.Feature.prototype.removeHooks.call(this);
|
84
|
+
|
85
|
+
this._clearHideErrorTimeout();
|
86
|
+
|
87
|
+
this._cleanUpShape();
|
88
|
+
|
89
|
+
// remove markers from map
|
90
|
+
this._map.removeLayer(this._markerGroup);
|
91
|
+
delete this._markerGroup;
|
92
|
+
delete this._markers;
|
93
|
+
|
94
|
+
this._map.removeLayer(this._poly);
|
95
|
+
delete this._poly;
|
96
|
+
|
97
|
+
this._mouseMarker.off('click', this._onClick, this);
|
98
|
+
this._map.removeLayer(this._mouseMarker);
|
99
|
+
delete this._mouseMarker;
|
100
|
+
|
101
|
+
// clean up DOM
|
102
|
+
this._clearGuides();
|
103
|
+
|
104
|
+
this._map
|
105
|
+
.off('mousemove', this._onMouseMove, this)
|
106
|
+
.off('zoomend', this._onZoomEnd, this);
|
107
|
+
},
|
108
|
+
|
109
|
+
_finishShape: function () {
|
110
|
+
var intersects = this._poly.newLatLngIntersects(this._poly.getLatLngs()[0], true);
|
111
|
+
|
112
|
+
if ((!this.options.allowIntersection && intersects) || !this._shapeIsValid()) {
|
113
|
+
this._showErrorTooltip();
|
114
|
+
return;
|
115
|
+
}
|
116
|
+
|
117
|
+
this._fireCreatedEvent();
|
118
|
+
this.disable();
|
119
|
+
},
|
120
|
+
|
121
|
+
//Called to verify the shape is valid when the user tries to finish it
|
122
|
+
//Return false if the shape is not valid
|
123
|
+
_shapeIsValid: function () {
|
124
|
+
return true;
|
125
|
+
},
|
126
|
+
|
127
|
+
_onZoomEnd: function () {
|
128
|
+
this._updateGuide();
|
129
|
+
},
|
130
|
+
|
131
|
+
_onMouseMove: function (e) {
|
132
|
+
var newPos = e.layerPoint,
|
133
|
+
latlng = e.latlng;
|
134
|
+
|
135
|
+
// Save latlng
|
136
|
+
// should this be moved to _updateGuide() ?
|
137
|
+
this._currentLatLng = latlng;
|
138
|
+
|
139
|
+
// Update the label
|
140
|
+
this._tooltip.updatePosition(latlng);
|
141
|
+
|
142
|
+
// Update the guide line
|
143
|
+
this._updateGuide(newPos);
|
144
|
+
|
145
|
+
// Update the mouse marker position
|
146
|
+
this._mouseMarker.setLatLng(latlng);
|
147
|
+
|
148
|
+
L.DomEvent.preventDefault(e.originalEvent);
|
149
|
+
},
|
150
|
+
|
151
|
+
_onClick: function (e) {
|
152
|
+
var latlng = e.target.getLatLng(),
|
153
|
+
markerCount = this._markers.length;
|
154
|
+
|
155
|
+
if (markerCount > 0 && !this.options.allowIntersection && this._poly.newLatLngIntersects(latlng)) {
|
156
|
+
this._showErrorTooltip();
|
157
|
+
return;
|
158
|
+
}
|
159
|
+
else if (this._errorShown) {
|
160
|
+
this._hideErrorTooltip();
|
161
|
+
}
|
162
|
+
|
163
|
+
this._markers.push(this._createMarker(latlng));
|
164
|
+
|
165
|
+
this._poly.addLatLng(latlng);
|
166
|
+
|
167
|
+
if (this._poly.getLatLngs().length === 2) {
|
168
|
+
this._map.addLayer(this._poly);
|
169
|
+
}
|
170
|
+
|
171
|
+
this._updateFinishHandler();
|
172
|
+
|
173
|
+
this._vertexAdded(latlng);
|
174
|
+
|
175
|
+
this._clearGuides();
|
176
|
+
},
|
177
|
+
|
178
|
+
_updateFinishHandler: function () {
|
179
|
+
var markerCount = this._markers.length;
|
180
|
+
// The last marker should have a click handler to close the polyline
|
181
|
+
if (markerCount > 1) {
|
182
|
+
this._markers[markerCount - 1].on('click', this._finishShape, this);
|
183
|
+
}
|
184
|
+
|
185
|
+
// Remove the old marker click handler (as only the last point should close the polyline)
|
186
|
+
if (markerCount > 2) {
|
187
|
+
this._markers[markerCount - 2].off('click', this._finishShape, this);
|
188
|
+
}
|
189
|
+
},
|
190
|
+
|
191
|
+
_createMarker: function (latlng) {
|
192
|
+
var marker = new L.Marker(latlng, {
|
193
|
+
icon: this.options.icon,
|
194
|
+
zIndexOffset: this.options.zIndexOffset * 2
|
195
|
+
});
|
196
|
+
|
197
|
+
this._markerGroup.addLayer(marker);
|
198
|
+
|
199
|
+
return marker;
|
200
|
+
},
|
201
|
+
|
202
|
+
_updateGuide: function (newPos) {
|
203
|
+
newPos = newPos || this._map.latLngToLayerPoint(this._currentLatLng);
|
204
|
+
|
205
|
+
var markerCount = this._markers.length;
|
206
|
+
|
207
|
+
if (markerCount > 0) {
|
208
|
+
// Update the tooltip text, as long it's not showing and error
|
209
|
+
if (!this._errorShown) {
|
210
|
+
this._tooltip.updateContent(this._getTooltipText());
|
211
|
+
}
|
212
|
+
|
213
|
+
// draw the guide line
|
214
|
+
this._clearGuides();
|
215
|
+
this._drawGuide(
|
216
|
+
this._map.latLngToLayerPoint(this._markers[markerCount - 1].getLatLng()),
|
217
|
+
newPos
|
218
|
+
);
|
219
|
+
}
|
220
|
+
},
|
221
|
+
|
222
|
+
_drawGuide: function (pointA, pointB) {
|
223
|
+
var length = Math.floor(Math.sqrt(Math.pow((pointB.x - pointA.x), 2) + Math.pow((pointB.y - pointA.y), 2))),
|
224
|
+
i,
|
225
|
+
fraction,
|
226
|
+
dashPoint,
|
227
|
+
dash;
|
228
|
+
|
229
|
+
//create the guides container if we haven't yet
|
230
|
+
if (!this._guidesContainer) {
|
231
|
+
this._guidesContainer = L.DomUtil.create('div', 'leaflet-draw-guides', this._overlayPane);
|
232
|
+
}
|
233
|
+
|
234
|
+
//draw a dash every GuildeLineDistance
|
235
|
+
for (i = this.options.guidelineDistance; i < length; i += this.options.guidelineDistance) {
|
236
|
+
//work out fraction along line we are
|
237
|
+
fraction = i / length;
|
238
|
+
|
239
|
+
//calculate new x,y point
|
240
|
+
dashPoint = {
|
241
|
+
x: Math.floor((pointA.x * (1 - fraction)) + (fraction * pointB.x)),
|
242
|
+
y: Math.floor((pointA.y * (1 - fraction)) + (fraction * pointB.y))
|
243
|
+
};
|
244
|
+
|
245
|
+
//add guide dash to guide container
|
246
|
+
dash = L.DomUtil.create('div', 'leaflet-draw-guide-dash', this._guidesContainer);
|
247
|
+
dash.style.backgroundColor =
|
248
|
+
!this._errorShown ? this.options.shapeOptions.color : this.options.drawError.color;
|
249
|
+
|
250
|
+
L.DomUtil.setPosition(dash, dashPoint);
|
251
|
+
}
|
252
|
+
},
|
253
|
+
|
254
|
+
_updateGuideColor: function (color) {
|
255
|
+
if (this._guidesContainer) {
|
256
|
+
for (var i = 0, l = this._guidesContainer.childNodes.length; i < l; i++) {
|
257
|
+
this._guidesContainer.childNodes[i].style.backgroundColor = color;
|
258
|
+
}
|
259
|
+
}
|
260
|
+
},
|
261
|
+
|
262
|
+
// removes all child elements (guide dashes) from the guides container
|
263
|
+
_clearGuides: function () {
|
264
|
+
if (this._guidesContainer) {
|
265
|
+
while (this._guidesContainer.firstChild) {
|
266
|
+
this._guidesContainer.removeChild(this._guidesContainer.firstChild);
|
267
|
+
}
|
268
|
+
}
|
269
|
+
},
|
270
|
+
|
271
|
+
_getTooltipText: function () {
|
272
|
+
var labelText,
|
273
|
+
distance,
|
274
|
+
distanceStr;
|
275
|
+
|
276
|
+
if (this._markers.length === 0) {
|
277
|
+
labelText = {
|
278
|
+
text: 'Click to start drawing line.'
|
279
|
+
};
|
280
|
+
} else {
|
281
|
+
// calculate the distance from the last fixed point to the mouse position
|
282
|
+
distance = this._measurementRunningTotal + this._currentLatLng.distanceTo(this._markers[this._markers.length - 1].getLatLng());
|
283
|
+
// show metres when distance is < 1km, then show km
|
284
|
+
distanceStr = distance > 1000 ? (distance / 1000).toFixed(2) + ' km' : Math.ceil(distance) + ' m';
|
285
|
+
|
286
|
+
if (this._markers.length === 1) {
|
287
|
+
labelText = {
|
288
|
+
text: 'Click to continue drawing line.',
|
289
|
+
subtext: distanceStr
|
290
|
+
};
|
291
|
+
} else {
|
292
|
+
labelText = {
|
293
|
+
text: 'Click last point to finish line.',
|
294
|
+
subtext: distanceStr
|
295
|
+
};
|
296
|
+
}
|
297
|
+
}
|
298
|
+
return labelText;
|
299
|
+
},
|
300
|
+
|
301
|
+
_showErrorTooltip: function () {
|
302
|
+
this._errorShown = true;
|
303
|
+
|
304
|
+
// Update tooltip
|
305
|
+
this._tooltip
|
306
|
+
.showAsError()
|
307
|
+
.updateContent({ text: this.options.drawError.message });
|
308
|
+
|
309
|
+
// Update shape
|
310
|
+
this._updateGuideColor(this.options.drawError.color);
|
311
|
+
this._poly.setStyle({ color: this.options.drawError.color });
|
312
|
+
|
313
|
+
// Hide the error after 2 seconds
|
314
|
+
this._clearHideErrorTimeout();
|
315
|
+
this._hideErrorTimeout = setTimeout(L.Util.bind(this._hideErrorTooltip, this), this.options.drawError.timeout);
|
316
|
+
},
|
317
|
+
|
318
|
+
_hideErrorTooltip: function () {
|
319
|
+
this._errorShown = false;
|
320
|
+
|
321
|
+
this._clearHideErrorTimeout();
|
322
|
+
|
323
|
+
// Revert tooltip
|
324
|
+
this._tooltip
|
325
|
+
.removeError()
|
326
|
+
.updateContent(this._getTooltipText());
|
327
|
+
|
328
|
+
// Revert shape
|
329
|
+
this._updateGuideColor(this.options.shapeOptions.color);
|
330
|
+
this._poly.setStyle({ color: this.options.shapeOptions.color });
|
331
|
+
},
|
332
|
+
|
333
|
+
_clearHideErrorTimeout: function () {
|
334
|
+
if (this._hideErrorTimeout) {
|
335
|
+
clearTimeout(this._hideErrorTimeout);
|
336
|
+
this._hideErrorTimeout = null;
|
337
|
+
}
|
338
|
+
},
|
339
|
+
|
340
|
+
_vertexAdded: function (latlng) {
|
341
|
+
if (this._markers.length === 1) {
|
342
|
+
this._measurementRunningTotal = 0;
|
343
|
+
}
|
344
|
+
else {
|
345
|
+
this._measurementRunningTotal +=
|
346
|
+
latlng.distanceTo(this._markers[this._markers.length - 2].getLatLng());
|
347
|
+
}
|
348
|
+
},
|
349
|
+
|
350
|
+
_cleanUpShape: function () {
|
351
|
+
if (this._markers.length > 0) {
|
352
|
+
this._markers[this._markers.length - 1].off('click', this._finishShape, this);
|
353
|
+
}
|
354
|
+
},
|
355
|
+
|
356
|
+
_fireCreatedEvent: function () {
|
357
|
+
var poly = new this.Poly(this._poly.getLatLngs(), this.options.shapeOptions);
|
358
|
+
L.Draw.Feature.prototype._fireCreatedEvent.call(this, poly);
|
359
|
+
}
|
360
|
+
});
|