leaflet-js 0.6.beta4 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/CHANGELOG.rdoc +3 -0
- data/leaflet-js.gemspec +2 -2
- data/lib/leaflet.draw/CHANGELOG.md +45 -0
- data/lib/leaflet.draw/README.md +70 -23
- data/lib/leaflet.draw/build/deps.js +1 -0
- data/lib/leaflet.draw/dist/images/spritesheet-2x.png +0 -0
- data/lib/leaflet.draw/dist/images/spritesheet.png +0 -0
- data/lib/leaflet.draw/dist/leaflet.draw-src.js +489 -136
- data/lib/leaflet.draw/dist/leaflet.draw.css +34 -2
- data/lib/leaflet.draw/dist/leaflet.draw.ie.css +5 -0
- data/lib/leaflet.draw/dist/leaflet.draw.js +2 -2
- data/lib/leaflet.draw/examples/basic.html +14 -7
- data/lib/leaflet.draw/examples/libs/images/layers-2x.png +0 -0
- data/lib/leaflet.draw/examples/libs/images/layers.png +0 -0
- data/lib/leaflet.draw/examples/libs/images/marker-icon-2x.png +0 -0
- data/lib/leaflet.draw/examples/libs/leaflet-src.js +1129 -608
- data/lib/leaflet.draw/examples/libs/leaflet.css +85 -66
- data/lib/leaflet.draw/package.json +2 -2
- data/lib/leaflet.draw/spec/suites/DrawControlSpec.js +1 -1
- data/lib/leaflet.draw/spec/suites/GeometryUtilSpec.js +25 -0
- data/lib/leaflet.draw/spec/suites/LatLngUtilSpec.js +9 -0
- data/lib/leaflet.draw/src/Control.Draw.js +1 -0
- data/lib/leaflet.draw/src/Leaflet.draw.js +89 -1
- data/lib/leaflet.draw/src/Toolbar.js +2 -6
- data/lib/leaflet.draw/src/Tooltip.js +20 -7
- data/lib/leaflet.draw/src/draw/DrawToolbar.js +26 -22
- data/lib/leaflet.draw/src/draw/handler/Draw.Circle.js +11 -6
- data/lib/leaflet.draw/src/draw/handler/Draw.Feature.js +6 -2
- data/lib/leaflet.draw/src/draw/handler/Draw.Marker.js +7 -2
- data/lib/leaflet.draw/src/draw/handler/Draw.Polygon.js +29 -7
- data/lib/leaflet.draw/src/draw/handler/Draw.Polyline.js +44 -21
- data/lib/leaflet.draw/src/draw/handler/Draw.Rectangle.js +3 -3
- data/lib/leaflet.draw/src/draw/handler/Draw.SimpleShape.js +14 -1
- data/lib/leaflet.draw/src/edit/EditToolbar.js +86 -16
- data/lib/leaflet.draw/src/edit/handler/Edit.Poly.js +10 -7
- data/lib/leaflet.draw/src/edit/handler/Edit.SimpleShape.js +1 -2
- data/lib/leaflet.draw/src/edit/handler/EditToolbar.Delete.js +15 -3
- data/lib/leaflet.draw/src/edit/handler/EditToolbar.Edit.js +56 -38
- data/lib/leaflet.draw/src/ext/GeometryUtil.js +68 -0
- data/lib/leaflet.draw/src/images/spritesheet.svg +41 -0
- data/lib/leaflet.label/CHANGELOG.md +32 -0
- data/lib/leaflet.label/README.md +21 -4
- data/lib/leaflet.label/build/build.js +2 -2
- data/lib/leaflet.label/build/deps.js +2 -0
- data/lib/leaflet.label/build/hintrc.js +4 -0
- data/lib/leaflet.label/dist/leaflet.label-src.js +266 -83
- data/lib/leaflet.label/dist/leaflet.label.css +23 -4
- data/lib/leaflet.label/dist/leaflet.label.js +1 -1
- data/lib/leaflet.label/example/label.html +6 -3
- data/lib/leaflet.label/libs/leaflet/images/layers-2x.png +0 -0
- data/lib/leaflet.label/libs/leaflet/images/layers.png +0 -0
- data/lib/leaflet.label/libs/leaflet/images/marker-icon-2x.png +0 -0
- data/lib/leaflet.label/libs/leaflet/leaflet-src.js +1129 -608
- data/lib/leaflet.label/libs/leaflet/leaflet.css +85 -66
- data/lib/leaflet.label/libs/leaflet/leaflet.js +6 -5
- data/lib/leaflet.label/package.json +19 -0
- data/lib/leaflet.label/src/BaseMarkerMethods.js +129 -0
- data/lib/leaflet.label/src/CircleMarker.Label.js +7 -0
- data/lib/leaflet.label/src/Label.js +161 -37
- data/lib/leaflet.label/src/Leaflet.label.js +1 -1
- data/lib/leaflet.label/src/Map.Label.js +0 -2
- data/lib/leaflet.label/src/Marker.Label.js +15 -120
- data/lib/leaflet.label/src/Path.Label.js +11 -11
- data/lib/leaflet/CHANGELOG.md +299 -31
- data/lib/leaflet/CONTRIBUTING.md +3 -3
- data/lib/leaflet/FAQ.md +138 -0
- data/lib/leaflet/Jakefile.js +24 -4
- data/lib/leaflet/PLUGIN-GUIDE.md +127 -0
- data/lib/leaflet/README.md +10 -6
- data/lib/leaflet/build/build.html +3 -19
- data/lib/leaflet/build/build.js +21 -51
- data/lib/leaflet/build/deps.js +10 -7
- data/lib/leaflet/build/hintrc.js +6 -4
- data/lib/leaflet/debug/hacks/jitter.html +0 -1
- data/lib/leaflet/debug/map/canvas.html +11 -12
- data/lib/leaflet/debug/map/controls.html +3 -4
- data/lib/leaflet/debug/map/geolocation.html +0 -1
- data/lib/leaflet/debug/map/iframe.html +11 -0
- data/lib/leaflet/debug/map/image-overlay.html +0 -1
- data/lib/leaflet/debug/map/map-mobile.html +0 -1
- data/lib/leaflet/debug/map/map.html +1 -2
- data/lib/leaflet/debug/map/max-bounds.html +2 -1
- data/lib/leaflet/debug/map/opacity.html +223 -0
- data/lib/leaflet/debug/map/scroll.html +6 -1
- data/lib/leaflet/debug/map/simple-proj.html +0 -1
- data/lib/leaflet/debug/map/wms-marble.html +4 -5
- data/lib/leaflet/debug/map/wms.html +0 -1
- data/lib/leaflet/debug/map/zoomlevels.html +0 -1
- data/lib/leaflet/debug/tests/add_remove_layers.html +5 -6
- data/lib/leaflet/debug/tests/bringtoback.html +0 -1
- data/lib/leaflet/debug/tests/canvasloop.html +47 -0
- data/lib/leaflet/debug/tests/click_on_canvas.html +0 -1
- data/lib/leaflet/debug/tests/dragging_and_copyworldjump.html +61 -0
- data/lib/leaflet/debug/tests/opacity.html +0 -1
- data/lib/leaflet/debug/tests/popupcontextmenuclicks.html +59 -0
- data/lib/leaflet/debug/tests/remove_while_dragging.html +4 -5
- data/lib/leaflet/debug/tests/removetilewhilepan.html +0 -1
- data/lib/leaflet/debug/tests/reuse_popups.html +0 -1
- data/lib/leaflet/debug/tests/rtl.html +42 -0
- data/lib/leaflet/debug/tests/rtl2.html +27 -0
- data/lib/leaflet/debug/tests/set_icon_reuse_dom.html +43 -0
- data/lib/leaflet/debug/tests/svg_clicks.html +3 -4
- data/lib/leaflet/debug/vector/bounds-extend.html +0 -1
- data/lib/leaflet/debug/vector/feature-group-bounds.html +0 -1
- data/lib/leaflet/debug/vector/geojson.html +0 -1
- data/lib/leaflet/debug/vector/rectangle.html +0 -1
- data/lib/leaflet/debug/vector/touchzoomemu.html +2 -3
- data/lib/leaflet/debug/vector/vector-bounds.html +0 -1
- data/lib/leaflet/debug/vector/vector-canvas.html +0 -1
- data/lib/leaflet/debug/vector/vector-mobile.html +0 -1
- data/lib/leaflet/debug/vector/vector-simple.html +0 -1
- data/lib/leaflet/debug/vector/vector.html +0 -1
- data/lib/leaflet/dist/images/layers-2x.png +0 -0
- data/lib/leaflet/dist/images/layers.png +0 -0
- data/lib/leaflet/dist/leaflet.css +85 -66
- data/lib/leaflet/package.json +25 -20
- data/lib/leaflet/spec/after.js +1 -1
- data/lib/leaflet/spec/index.html +21 -13
- data/lib/leaflet/spec/karma.conf.js +51 -50
- data/lib/leaflet/spec/spec.hintrc.js +25 -0
- data/lib/leaflet/spec/suites/LeafletSpec.js +2 -2
- data/lib/leaflet/spec/suites/SpecHelper.js +37 -21
- data/lib/leaflet/spec/suites/control/Control.LayersSpec.js +1 -1
- data/lib/leaflet/spec/suites/core/ClassSpec.js +12 -12
- data/lib/leaflet/spec/suites/core/EventsSpec.js +74 -18
- data/lib/leaflet/spec/suites/core/UtilSpec.js +69 -25
- data/lib/leaflet/spec/suites/dom/DomEventSpec.js +16 -16
- data/lib/leaflet/spec/suites/dom/DomUtilSpec.js +9 -16
- data/lib/leaflet/spec/suites/dom/PosAnimationSpec.js +27 -0
- data/lib/leaflet/spec/suites/geo/CRSSpec.js +47 -0
- data/lib/leaflet/spec/suites/geo/LatLngBoundsSpec.js +22 -14
- data/lib/leaflet/spec/suites/geo/LatLngSpec.js +22 -8
- data/lib/leaflet/spec/suites/geo/ProjectionSpec.js +21 -20
- data/lib/leaflet/spec/suites/geometry/BoundsSpec.js +15 -15
- data/lib/leaflet/spec/suites/geometry/PointSpec.js +12 -12
- data/lib/leaflet/spec/suites/geometry/TransformationSpec.js +4 -4
- data/lib/leaflet/spec/suites/layer/FeatureGroupSpec.js +59 -9
- data/lib/leaflet/spec/suites/layer/GeoJSONSpec.js +213 -17
- data/lib/leaflet/spec/suites/layer/LayerGroupSpec.js +6 -6
- data/lib/leaflet/spec/suites/layer/PopupSpec.js +65 -5
- data/lib/leaflet/spec/suites/layer/TileLayerSpec.js +16 -15
- data/lib/leaflet/spec/suites/layer/marker/MarkerSpec.js +94 -0
- data/lib/leaflet/spec/suites/layer/vector/CircleMarkerSpec.js +7 -7
- data/lib/leaflet/spec/suites/layer/vector/PolygonSpec.js +38 -2
- data/lib/leaflet/spec/suites/layer/vector/PolylineGeometrySpec.js +4 -4
- data/lib/leaflet/spec/suites/layer/vector/PolylineSpec.js +2 -2
- data/lib/leaflet/spec/suites/map/MapSpec.js +318 -26
- data/lib/leaflet/spec/suites/map/handler/Map.DragSpec.js +38 -0
- data/lib/leaflet/src/Leaflet.js +2 -2
- data/lib/leaflet/src/control/Control.Attribution.js +6 -0
- data/lib/leaflet/src/control/Control.Layers.js +33 -24
- data/lib/leaflet/src/control/Control.Zoom.js +12 -4
- data/lib/leaflet/src/control/Control.js +10 -0
- data/lib/leaflet/src/copyright.js +2 -1
- data/lib/leaflet/src/core/Browser.js +11 -10
- data/lib/leaflet/src/core/Events.js +15 -11
- data/lib/leaflet/src/core/Util.js +19 -14
- data/lib/leaflet/src/dom/DomEvent.DoubleTap.js +13 -12
- data/lib/leaflet/src/dom/DomEvent.Pointer.js +155 -0
- data/lib/leaflet/src/dom/DomEvent.js +57 -19
- data/lib/leaflet/src/dom/DomUtil.js +89 -34
- data/lib/leaflet/src/dom/Draggable.js +26 -89
- data/lib/leaflet/src/dom/PosAnimation.js +13 -2
- data/lib/leaflet/src/geo/LatLng.js +16 -5
- data/lib/leaflet/src/geo/LatLngBounds.js +5 -2
- data/lib/leaflet/src/geo/crs/CRS.EPSG3395.js +2 -2
- data/lib/leaflet/src/geo/crs/CRS.js +5 -0
- data/lib/leaflet/src/geo/projection/Projection.Mercator.js +3 -3
- data/lib/leaflet/src/geometry/LineUtil.js +2 -2
- data/lib/leaflet/src/images/layers.svg +8 -0
- data/lib/leaflet/src/images/marker.svg +61 -1
- data/lib/leaflet/src/layer/FeatureGroup.js +24 -7
- data/lib/leaflet/src/layer/GeoJSON.js +97 -56
- data/lib/leaflet/src/layer/ImageOverlay.js +9 -0
- data/lib/leaflet/src/layer/LayerGroup.js +8 -3
- data/lib/leaflet/src/layer/Popup.js +56 -34
- data/lib/leaflet/src/layer/marker/DivIcon.js +4 -2
- data/lib/leaflet/src/layer/marker/Icon.Default.js +1 -1
- data/lib/leaflet/src/layer/marker/Icon.js +15 -18
- data/lib/leaflet/src/layer/marker/Marker.Drag.js +7 -5
- data/lib/leaflet/src/layer/marker/Marker.Popup.js +22 -5
- data/lib/leaflet/src/layer/marker/Marker.js +75 -32
- data/lib/leaflet/src/layer/tile/TileLayer.Anim.js +14 -26
- data/lib/leaflet/src/layer/tile/TileLayer.Canvas.js +7 -6
- data/lib/leaflet/src/layer/tile/TileLayer.WMS.js +14 -10
- data/lib/leaflet/src/layer/tile/TileLayer.js +53 -32
- data/lib/leaflet/src/layer/vector/CircleMarker.js +11 -0
- data/lib/leaflet/src/layer/vector/MultiPoly.js +10 -0
- data/lib/leaflet/src/layer/vector/Path.SVG.js +14 -3
- data/lib/leaflet/src/layer/vector/Path.VML.js +12 -2
- data/lib/leaflet/src/layer/vector/Path.js +7 -3
- data/lib/leaflet/src/layer/vector/Polygon.js +14 -3
- data/lib/leaflet/src/layer/vector/canvas/CircleMarker.Canvas.js +9 -0
- data/lib/leaflet/src/layer/vector/canvas/Path.Canvas.js +1 -0
- data/lib/leaflet/src/map/Map.js +192 -125
- data/lib/leaflet/src/map/anim/Map.PanAnimation.js +29 -19
- data/lib/leaflet/src/map/anim/Map.ZoomAnimation.js +21 -9
- data/lib/leaflet/src/map/ext/Map.Geolocation.js +11 -4
- data/lib/leaflet/src/map/handler/Map.BoxZoom.js +26 -12
- data/lib/leaflet/src/map/handler/Map.DoubleClickZoom.js +10 -3
- data/lib/leaflet/src/map/handler/Map.Drag.js +12 -6
- data/lib/leaflet/src/map/handler/Map.Keyboard.js +5 -2
- data/lib/leaflet/src/map/handler/Map.ScrollWheelZoom.js +7 -1
- data/lib/leaflet/src/map/handler/Map.Tap.js +107 -0
- data/lib/leaflet/src/map/handler/Map.TouchZoom.js +9 -3
- data/vendor/assets/images/layers-2x.png +0 -0
- data/vendor/assets/images/layers.png +0 -0
- data/vendor/assets/images/spritesheet-2x.png +0 -0
- data/vendor/assets/images/spritesheet.png +0 -0
- data/vendor/assets/javascripts/leaflet.draw.js +2 -4
- data/vendor/assets/javascripts/leaflet.js +3 -1
- data/vendor/assets/javascripts/leaflet.label.js +2 -0
- data/vendor/assets/stylesheets/leaflet.css.erb +337 -318
- data/vendor/assets/stylesheets/leaflet.draw.css.erb +35 -3
- data/vendor/assets/stylesheets/leaflet.draw.ie.css +5 -0
- data/vendor/assets/stylesheets/leaflet.label.css +23 -4
- metadata +40 -14
- data/lib/leaflet.draw/examples/libs/leaflet.ie.css +0 -51
- data/lib/leaflet.label/libs/leaflet/leaflet.ie.css +0 -51
- data/lib/leaflet/dist/leaflet-src.js +0 -8579
- data/lib/leaflet/dist/leaflet.ie.css +0 -51
- data/lib/leaflet/dist/leaflet.js +0 -8
- data/lib/leaflet/spec/happen.js +0 -93
- data/lib/leaflet/src/dom/DomEvent.MsTouch.js +0 -146
- data/vendor/assets/stylesheets/leaflet.ie.css +0 -51
@@ -45,7 +45,7 @@ L.Toolbar = L.Class.extend({
|
|
45
45
|
this._actionsContainer = null;
|
46
46
|
},
|
47
47
|
|
48
|
-
_initModeHandler: function (handler, container, buttonIndex, classNamePredix) {
|
48
|
+
_initModeHandler: function (handler, container, buttonIndex, classNamePredix, buttonTitle) {
|
49
49
|
var type = handler.type;
|
50
50
|
|
51
51
|
this._modes[type] = {};
|
@@ -53,7 +53,7 @@ L.Toolbar = L.Class.extend({
|
|
53
53
|
this._modes[type].handler = handler;
|
54
54
|
|
55
55
|
this._modes[type].button = this._createButton({
|
56
|
-
title:
|
56
|
+
title: buttonTitle,
|
57
57
|
className: classNamePredix + '-' + type,
|
58
58
|
container: container,
|
59
59
|
callback: this._modes[type].handler.enable,
|
@@ -126,9 +126,7 @@ L.Toolbar = L.Class.extend({
|
|
126
126
|
|
127
127
|
_createActions: function (buttons) {
|
128
128
|
var container = L.DomUtil.create('ul', 'leaflet-draw-actions'),
|
129
|
-
buttonWidth = 50,
|
130
129
|
l = buttons.length,
|
131
|
-
containerWidth = (l * buttonWidth) + (l - 1), //l - 1 = the borders
|
132
130
|
li, button;
|
133
131
|
|
134
132
|
for (var i = 0; i < l; i++) {
|
@@ -148,8 +146,6 @@ L.Toolbar = L.Class.extend({
|
|
148
146
|
});
|
149
147
|
}
|
150
148
|
|
151
|
-
container.style.width = containerWidth + 'px';
|
152
|
-
|
153
149
|
return container;
|
154
150
|
},
|
155
151
|
|
@@ -3,16 +3,21 @@ L.Tooltip = L.Class.extend({
|
|
3
3
|
this._map = map;
|
4
4
|
this._popupPane = map._panes.popupPane;
|
5
5
|
|
6
|
-
this._container = L.DomUtil.create('div', 'leaflet-draw-tooltip', this._popupPane);
|
6
|
+
this._container = map.options.drawControlTooltips ? L.DomUtil.create('div', 'leaflet-draw-tooltip', this._popupPane) : null;
|
7
7
|
this._singleLineLabel = false;
|
8
8
|
},
|
9
9
|
|
10
10
|
dispose: function () {
|
11
|
-
|
12
|
-
|
11
|
+
if (this._container) {
|
12
|
+
this._popupPane.removeChild(this._container);
|
13
|
+
this._container = null;
|
14
|
+
}
|
13
15
|
},
|
14
16
|
|
15
17
|
updateContent: function (labelText) {
|
18
|
+
if (!this._container) {
|
19
|
+
return this;
|
20
|
+
}
|
16
21
|
labelText.subtext = labelText.subtext || '';
|
17
22
|
|
18
23
|
// update the vertical position (only if changed)
|
@@ -33,20 +38,28 @@ L.Tooltip = L.Class.extend({
|
|
33
38
|
},
|
34
39
|
|
35
40
|
updatePosition: function (latlng) {
|
36
|
-
var pos = this._map.latLngToLayerPoint(latlng)
|
41
|
+
var pos = this._map.latLngToLayerPoint(latlng),
|
42
|
+
tooltipContainer = this._container;
|
37
43
|
|
38
|
-
|
44
|
+
if (this._container) {
|
45
|
+
tooltipContainer.style.visibility = 'inherit';
|
46
|
+
L.DomUtil.setPosition(tooltipContainer, pos);
|
47
|
+
}
|
39
48
|
|
40
49
|
return this;
|
41
50
|
},
|
42
51
|
|
43
52
|
showAsError: function () {
|
44
|
-
|
53
|
+
if (this._container) {
|
54
|
+
L.DomUtil.addClass(this._container, 'leaflet-error-draw-tooltip');
|
55
|
+
}
|
45
56
|
return this;
|
46
57
|
},
|
47
58
|
|
48
59
|
removeError: function () {
|
49
|
-
|
60
|
+
if (this._container) {
|
61
|
+
L.DomUtil.removeClass(this._container, 'leaflet-error-draw-tooltip');
|
62
|
+
}
|
50
63
|
return this;
|
51
64
|
}
|
52
65
|
});
|
@@ -1,24 +1,23 @@
|
|
1
1
|
L.DrawToolbar = L.Toolbar.extend({
|
2
2
|
|
3
3
|
options: {
|
4
|
-
polyline: {
|
5
|
-
|
6
|
-
},
|
7
|
-
|
8
|
-
|
9
|
-
},
|
10
|
-
rectangle: {
|
11
|
-
title: 'Draw a rectangle'
|
12
|
-
},
|
13
|
-
circle: {
|
14
|
-
title: 'Draw a circle'
|
15
|
-
},
|
16
|
-
marker: {
|
17
|
-
title: 'Add a marker'
|
18
|
-
}
|
4
|
+
polyline: {},
|
5
|
+
polygon: {},
|
6
|
+
rectangle: {},
|
7
|
+
circle: {},
|
8
|
+
marker: {}
|
19
9
|
},
|
20
10
|
|
21
11
|
initialize: function (options) {
|
12
|
+
// Ensure that the options are merged correctly since L.extend is only shallow
|
13
|
+
for (var type in this.options) {
|
14
|
+
if (this.options.hasOwnProperty(type)) {
|
15
|
+
if (options[type]) {
|
16
|
+
options[type] = L.extend({}, this.options[type], options[type]);
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
22
21
|
L.Toolbar.prototype.initialize.call(this, options);
|
23
22
|
},
|
24
23
|
|
@@ -35,7 +34,8 @@ L.DrawToolbar = L.Toolbar.extend({
|
|
35
34
|
new L.Draw.Polyline(map, this.options.polyline),
|
36
35
|
this._toolbarContainer,
|
37
36
|
buttonIndex++,
|
38
|
-
buttonClassPrefix
|
37
|
+
buttonClassPrefix,
|
38
|
+
L.drawLocal.draw.toolbar.buttons.polyline
|
39
39
|
);
|
40
40
|
}
|
41
41
|
|
@@ -44,7 +44,8 @@ L.DrawToolbar = L.Toolbar.extend({
|
|
44
44
|
new L.Draw.Polygon(map, this.options.polygon),
|
45
45
|
this._toolbarContainer,
|
46
46
|
buttonIndex++,
|
47
|
-
buttonClassPrefix
|
47
|
+
buttonClassPrefix,
|
48
|
+
L.drawLocal.draw.toolbar.buttons.polygon
|
48
49
|
);
|
49
50
|
}
|
50
51
|
|
@@ -53,7 +54,8 @@ L.DrawToolbar = L.Toolbar.extend({
|
|
53
54
|
new L.Draw.Rectangle(map, this.options.rectangle),
|
54
55
|
this._toolbarContainer,
|
55
56
|
buttonIndex++,
|
56
|
-
buttonClassPrefix
|
57
|
+
buttonClassPrefix,
|
58
|
+
L.drawLocal.draw.toolbar.buttons.rectangle
|
57
59
|
);
|
58
60
|
}
|
59
61
|
|
@@ -62,7 +64,8 @@ L.DrawToolbar = L.Toolbar.extend({
|
|
62
64
|
new L.Draw.Circle(map, this.options.circle),
|
63
65
|
this._toolbarContainer,
|
64
66
|
buttonIndex++,
|
65
|
-
buttonClassPrefix
|
67
|
+
buttonClassPrefix,
|
68
|
+
L.drawLocal.draw.toolbar.buttons.circle
|
66
69
|
);
|
67
70
|
}
|
68
71
|
|
@@ -71,7 +74,8 @@ L.DrawToolbar = L.Toolbar.extend({
|
|
71
74
|
new L.Draw.Marker(map, this.options.marker),
|
72
75
|
this._toolbarContainer,
|
73
76
|
buttonIndex++,
|
74
|
-
buttonClassPrefix
|
77
|
+
buttonClassPrefix,
|
78
|
+
L.drawLocal.draw.toolbar.buttons.marker
|
75
79
|
);
|
76
80
|
}
|
77
81
|
|
@@ -81,8 +85,8 @@ L.DrawToolbar = L.Toolbar.extend({
|
|
81
85
|
// Create the actions part of the toolbar
|
82
86
|
this._actionsContainer = this._createActions([
|
83
87
|
{
|
84
|
-
title:
|
85
|
-
text:
|
88
|
+
title: L.drawLocal.draw.toolbar.actions.title,
|
89
|
+
text: L.drawLocal.draw.toolbar.actions.text,
|
86
90
|
callback: this.disable,
|
87
91
|
context: this
|
88
92
|
}
|
@@ -13,18 +13,20 @@ L.Draw.Circle = L.Draw.SimpleShape.extend({
|
|
13
13
|
fillColor: null, //same as color by default
|
14
14
|
fillOpacity: 0.2,
|
15
15
|
clickable: true
|
16
|
-
}
|
16
|
+
},
|
17
|
+
showRadius: true,
|
18
|
+
metric: true // Whether to use the metric meaurement system or imperial
|
17
19
|
},
|
18
20
|
|
19
21
|
initialize: function (map, options) {
|
20
22
|
// Save the type so super can fire, need to do this as cannot do this.TYPE :(
|
21
23
|
this.type = L.Draw.Circle.TYPE;
|
22
24
|
|
25
|
+
this._initialLabelText = L.drawLocal.draw.handlers.circle.tooltip.start;
|
26
|
+
|
23
27
|
L.Draw.SimpleShape.prototype.initialize.call(this, map, options);
|
24
28
|
},
|
25
29
|
|
26
|
-
_initialLabelText: 'Click and drag to draw circle.',
|
27
|
-
|
28
30
|
_drawShape: function (latlng) {
|
29
31
|
if (!this._shape) {
|
30
32
|
this._shape = new L.Circle(this._startLatLng, this._startLatLng.distanceTo(latlng), this.options.shapeOptions);
|
@@ -41,6 +43,9 @@ L.Draw.Circle = L.Draw.SimpleShape.extend({
|
|
41
43
|
|
42
44
|
_onMouseMove: function (e) {
|
43
45
|
var latlng = e.latlng,
|
46
|
+
metric = this.options.metric,
|
47
|
+
showRadius = this.options.showRadius,
|
48
|
+
useMetric = this.options.metric,
|
44
49
|
radius;
|
45
50
|
|
46
51
|
this._tooltip.updatePosition(latlng);
|
@@ -51,9 +56,9 @@ L.Draw.Circle = L.Draw.SimpleShape.extend({
|
|
51
56
|
radius = this._shape.getRadius().toFixed(1);
|
52
57
|
|
53
58
|
this._tooltip.updateContent({
|
54
|
-
text:
|
55
|
-
subtext: 'Radius: ' + radius
|
59
|
+
text: this._endLabelText,
|
60
|
+
subtext: showRadius ? 'Radius: ' + L.GeometryUtil.readableDistance(radius, useMetric) : ''
|
56
61
|
});
|
57
62
|
}
|
58
63
|
}
|
59
|
-
});
|
64
|
+
});
|
@@ -13,7 +13,7 @@ L.Draw.Feature = L.Handler.extend({
|
|
13
13
|
if (options && options.shapeOptions) {
|
14
14
|
options.shapeOptions = L.Util.extend({}, this.options.shapeOptions, options.shapeOptions);
|
15
15
|
}
|
16
|
-
L.
|
16
|
+
L.setOptions(this, options);
|
17
17
|
},
|
18
18
|
|
19
19
|
enable: function () {
|
@@ -37,9 +37,13 @@ L.Draw.Feature = L.Handler.extend({
|
|
37
37
|
},
|
38
38
|
|
39
39
|
addHooks: function () {
|
40
|
-
|
40
|
+
var map = this._map;
|
41
|
+
|
42
|
+
if (map) {
|
41
43
|
L.DomUtil.disableTextSelection();
|
42
44
|
|
45
|
+
map.getContainer().focus();
|
46
|
+
|
43
47
|
this._tooltip = new L.Tooltip(this._map);
|
44
48
|
|
45
49
|
L.DomEvent.addListener(this._container, 'keyup', this._cancelDrawing, this);
|
@@ -5,6 +5,7 @@ L.Draw.Marker = L.Draw.Feature.extend({
|
|
5
5
|
|
6
6
|
options: {
|
7
7
|
icon: new L.Icon.Default(),
|
8
|
+
repeatMode: false,
|
8
9
|
zIndexOffset: 2000 // This should be > than the highest z-index any markers
|
9
10
|
},
|
10
11
|
|
@@ -19,7 +20,7 @@ L.Draw.Marker = L.Draw.Feature.extend({
|
|
19
20
|
L.Draw.Feature.prototype.addHooks.call(this);
|
20
21
|
|
21
22
|
if (this._map) {
|
22
|
-
this._tooltip.updateContent({ text:
|
23
|
+
this._tooltip.updateContent({ text: L.drawLocal.draw.handlers.marker.tooltip.start });
|
23
24
|
|
24
25
|
// Same mouseMarker as in Draw.Polyline
|
25
26
|
if (!this._mouseMarker) {
|
@@ -80,6 +81,7 @@ L.Draw.Marker = L.Draw.Feature.extend({
|
|
80
81
|
.addLayer(this._marker);
|
81
82
|
}
|
82
83
|
else {
|
84
|
+
latlng = this._mouseMarker.getLatLng();
|
83
85
|
this._marker.setLatLng(latlng);
|
84
86
|
}
|
85
87
|
},
|
@@ -88,10 +90,13 @@ L.Draw.Marker = L.Draw.Feature.extend({
|
|
88
90
|
this._fireCreatedEvent();
|
89
91
|
|
90
92
|
this.disable();
|
93
|
+
if (this.options.repeatMode) {
|
94
|
+
this.enable();
|
95
|
+
}
|
91
96
|
},
|
92
97
|
|
93
98
|
_fireCreatedEvent: function () {
|
94
99
|
var marker = new L.Marker(this._marker.getLatLng(), { icon: this.options.icon });
|
95
100
|
L.Draw.Feature.prototype._fireCreatedEvent.call(this, marker);
|
96
101
|
}
|
97
|
-
});
|
102
|
+
});
|
@@ -6,6 +6,7 @@ L.Draw.Polygon = L.Draw.Polyline.extend({
|
|
6
6
|
Poly: L.Polygon,
|
7
7
|
|
8
8
|
options: {
|
9
|
+
showArea: false,
|
9
10
|
shapeOptions: {
|
10
11
|
stroke: true,
|
11
12
|
color: '#f06eaa',
|
@@ -44,25 +45,46 @@ L.Draw.Polygon = L.Draw.Polyline.extend({
|
|
44
45
|
},
|
45
46
|
|
46
47
|
_getTooltipText: function () {
|
47
|
-
var text;
|
48
|
+
var text, subtext;
|
49
|
+
|
48
50
|
if (this._markers.length === 0) {
|
49
|
-
text =
|
51
|
+
text = L.drawLocal.draw.handlers.polygon.tooltip.start;
|
50
52
|
} else if (this._markers.length < 3) {
|
51
|
-
text =
|
53
|
+
text = L.drawLocal.draw.handlers.polygon.tooltip.cont;
|
52
54
|
} else {
|
53
|
-
text =
|
55
|
+
text = L.drawLocal.draw.handlers.polygon.tooltip.end;
|
56
|
+
subtext = this._getMeasurementString();
|
54
57
|
}
|
58
|
+
|
55
59
|
return {
|
56
|
-
text: text
|
60
|
+
text: text,
|
61
|
+
subtext: subtext
|
57
62
|
};
|
58
63
|
},
|
59
64
|
|
65
|
+
_getMeasurementString: function () {
|
66
|
+
var area = this._area;
|
67
|
+
|
68
|
+
if (!area) {
|
69
|
+
return null;
|
70
|
+
}
|
71
|
+
|
72
|
+
return L.GeometryUtil.readableArea(area, this.options.metric);
|
73
|
+
},
|
74
|
+
|
60
75
|
_shapeIsValid: function () {
|
61
76
|
return this._markers.length >= 3;
|
62
77
|
},
|
63
78
|
|
64
79
|
_vertexAdded: function () {
|
65
|
-
//
|
80
|
+
// Check to see if we should show the area
|
81
|
+
if (this.options.allowIntersection || !this.options.showArea) {
|
82
|
+
return;
|
83
|
+
}
|
84
|
+
|
85
|
+
var latLngs = this._poly.getLatLngs();
|
86
|
+
|
87
|
+
this._area = L.GeometryUtil.geodesicArea(latLngs);
|
66
88
|
},
|
67
89
|
|
68
90
|
_cleanUpShape: function () {
|
@@ -76,4 +98,4 @@ L.Draw.Polygon = L.Draw.Polyline.extend({
|
|
76
98
|
}
|
77
99
|
}
|
78
100
|
}
|
79
|
-
});
|
101
|
+
});
|
@@ -7,9 +7,9 @@ L.Draw.Polyline = L.Draw.Feature.extend({
|
|
7
7
|
|
8
8
|
options: {
|
9
9
|
allowIntersection: true,
|
10
|
+
repeatMode: false,
|
10
11
|
drawError: {
|
11
12
|
color: '#b00b00',
|
12
|
-
message: '<strong>Error:</strong> shape edges cannot cross!',
|
13
13
|
timeout: 2500
|
14
14
|
},
|
15
15
|
icon: new L.DivIcon({
|
@@ -25,10 +25,15 @@ L.Draw.Polyline = L.Draw.Feature.extend({
|
|
25
25
|
fill: false,
|
26
26
|
clickable: true
|
27
27
|
},
|
28
|
+
metric: true, // Whether to use the metric meaurement system or imperial
|
29
|
+
showLength: true, // Whether to display distance in the tooltip
|
28
30
|
zIndexOffset: 2000 // This should be > than the highest z-index any map layers
|
29
31
|
},
|
30
32
|
|
31
33
|
initialize: function (map, options) {
|
34
|
+
// Need to set this here to ensure the correct message is used.
|
35
|
+
this.options.drawError.message = L.drawLocal.draw.handlers.polyline.error;
|
36
|
+
|
32
37
|
// Merge default drawError options with custom options
|
33
38
|
if (options && options.drawError) {
|
34
39
|
options.drawError = L.Util.extend({}, this.options.drawError, options.drawError);
|
@@ -116,6 +121,9 @@ L.Draw.Polyline = L.Draw.Feature.extend({
|
|
116
121
|
|
117
122
|
this._fireCreatedEvent();
|
118
123
|
this.disable();
|
124
|
+
if (this.options.repeatMode) {
|
125
|
+
this.enable();
|
126
|
+
}
|
119
127
|
},
|
120
128
|
|
121
129
|
//Called to verify the shape is valid when the user tries to finish it
|
@@ -136,8 +144,7 @@ L.Draw.Polyline = L.Draw.Feature.extend({
|
|
136
144
|
// should this be moved to _updateGuide() ?
|
137
145
|
this._currentLatLng = latlng;
|
138
146
|
|
139
|
-
|
140
|
-
this._tooltip.updatePosition(latlng);
|
147
|
+
this._updateTooltip(latlng);
|
141
148
|
|
142
149
|
// Update the guide line
|
143
150
|
this._updateGuide(newPos);
|
@@ -173,6 +180,8 @@ L.Draw.Polyline = L.Draw.Feature.extend({
|
|
173
180
|
this._vertexAdded(latlng);
|
174
181
|
|
175
182
|
this._clearGuides();
|
183
|
+
|
184
|
+
this._updateTooltip();
|
176
185
|
},
|
177
186
|
|
178
187
|
_updateFinishHandler: function () {
|
@@ -200,15 +209,10 @@ L.Draw.Polyline = L.Draw.Feature.extend({
|
|
200
209
|
},
|
201
210
|
|
202
211
|
_updateGuide: function (newPos) {
|
203
|
-
newPos = newPos || this._map.latLngToLayerPoint(this._currentLatLng);
|
204
|
-
|
205
212
|
var markerCount = this._markers.length;
|
206
213
|
|
207
214
|
if (markerCount > 0) {
|
208
|
-
|
209
|
-
if (!this._errorShown) {
|
210
|
-
this._tooltip.updateContent(this._getTooltipText());
|
211
|
-
}
|
215
|
+
newPos = newPos || this._map.latLngToLayerPoint(this._currentLatLng);
|
212
216
|
|
213
217
|
// draw the guide line
|
214
218
|
this._clearGuides();
|
@@ -219,6 +223,18 @@ L.Draw.Polyline = L.Draw.Feature.extend({
|
|
219
223
|
}
|
220
224
|
},
|
221
225
|
|
226
|
+
_updateTooltip: function (latLng) {
|
227
|
+
var text = this._getTooltipText();
|
228
|
+
|
229
|
+
if (latLng) {
|
230
|
+
this._tooltip.updatePosition(latLng);
|
231
|
+
}
|
232
|
+
|
233
|
+
if (!this._errorShown) {
|
234
|
+
this._tooltip.updateContent(text);
|
235
|
+
}
|
236
|
+
},
|
237
|
+
|
222
238
|
_drawGuide: function (pointA, pointB) {
|
223
239
|
var length = Math.floor(Math.sqrt(Math.pow((pointB.x - pointA.x), 2) + Math.pow((pointB.y - pointA.y), 2))),
|
224
240
|
i,
|
@@ -269,28 +285,24 @@ L.Draw.Polyline = L.Draw.Feature.extend({
|
|
269
285
|
},
|
270
286
|
|
271
287
|
_getTooltipText: function () {
|
272
|
-
var
|
273
|
-
distance,
|
274
|
-
distanceStr;
|
288
|
+
var showLength = this.options.showLength,
|
289
|
+
labelText, distance, distanceStr;
|
275
290
|
|
276
291
|
if (this._markers.length === 0) {
|
277
292
|
labelText = {
|
278
|
-
text:
|
293
|
+
text: L.drawLocal.draw.handlers.polyline.tooltip.start
|
279
294
|
};
|
280
295
|
} else {
|
281
|
-
|
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';
|
296
|
+
distanceStr = showLength ? this._getMeasurementString() : '';
|
285
297
|
|
286
298
|
if (this._markers.length === 1) {
|
287
299
|
labelText = {
|
288
|
-
text:
|
300
|
+
text: L.drawLocal.draw.handlers.polyline.tooltip.cont,
|
289
301
|
subtext: distanceStr
|
290
302
|
};
|
291
303
|
} else {
|
292
304
|
labelText = {
|
293
|
-
text:
|
305
|
+
text: L.drawLocal.draw.handlers.polyline.tooltip.end,
|
294
306
|
subtext: distanceStr
|
295
307
|
};
|
296
308
|
}
|
@@ -298,6 +310,17 @@ L.Draw.Polyline = L.Draw.Feature.extend({
|
|
298
310
|
return labelText;
|
299
311
|
},
|
300
312
|
|
313
|
+
_getMeasurementString: function () {
|
314
|
+
var currentLatLng = this._currentLatLng,
|
315
|
+
previousLatLng = this._markers[this._markers.length - 1].getLatLng(),
|
316
|
+
distance;
|
317
|
+
|
318
|
+
// calculate the distance from the last fixed point to the mouse position
|
319
|
+
distance = this._measurementRunningTotal + currentLatLng.distanceTo(previousLatLng);
|
320
|
+
|
321
|
+
return L.GeometryUtil.readableDistance(distance, this.options.metric);
|
322
|
+
},
|
323
|
+
|
301
324
|
_showErrorTooltip: function () {
|
302
325
|
this._errorShown = true;
|
303
326
|
|
@@ -348,7 +371,7 @@ L.Draw.Polyline = L.Draw.Feature.extend({
|
|
348
371
|
},
|
349
372
|
|
350
373
|
_cleanUpShape: function () {
|
351
|
-
if (this._markers.length >
|
374
|
+
if (this._markers.length > 1) {
|
352
375
|
this._markers[this._markers.length - 1].off('click', this._finishShape, this);
|
353
376
|
}
|
354
377
|
},
|
@@ -357,4 +380,4 @@ L.Draw.Polyline = L.Draw.Feature.extend({
|
|
357
380
|
var poly = new this.Poly(this._poly.getLatLngs(), this.options.shapeOptions);
|
358
381
|
L.Draw.Feature.prototype._fireCreatedEvent.call(this, poly);
|
359
382
|
}
|
360
|
-
});
|
383
|
+
});
|