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
@@ -1,11 +1,23 @@
|
|
1
|
-
L.Label = L.
|
1
|
+
L.Label = L.Class.extend({
|
2
|
+
|
3
|
+
includes: L.Mixin.Events,
|
4
|
+
|
2
5
|
options: {
|
3
|
-
autoPan: false,
|
4
6
|
className: '',
|
5
|
-
|
7
|
+
clickable: false,
|
8
|
+
direction: 'right',
|
6
9
|
noHide: false,
|
7
|
-
offset:
|
8
|
-
opacity: 1
|
10
|
+
offset: [12, -15], // 6 (width of the label triangle) + 6 (padding)
|
11
|
+
opacity: 1,
|
12
|
+
zoomAnimation: true
|
13
|
+
},
|
14
|
+
|
15
|
+
initialize: function (options, source) {
|
16
|
+
L.setOptions(this, options);
|
17
|
+
|
18
|
+
this._source = source;
|
19
|
+
this._animated = L.Browser.any3d && this.options.zoomAnimation;
|
20
|
+
this._isOpen = false;
|
9
21
|
},
|
10
22
|
|
11
23
|
onAdd: function (map) {
|
@@ -16,16 +28,18 @@ L.Label = L.Popup.extend({
|
|
16
28
|
if (!this._container) {
|
17
29
|
this._initLayout();
|
18
30
|
}
|
19
|
-
this._updateContent();
|
20
|
-
|
21
|
-
var animFade = map.options.fadeAnimation;
|
22
31
|
|
23
|
-
if (animFade) {
|
24
|
-
L.DomUtil.setOpacity(this._container, 0);
|
25
|
-
}
|
26
32
|
this._pane.appendChild(this._container);
|
27
33
|
|
28
|
-
|
34
|
+
this._initInteraction();
|
35
|
+
|
36
|
+
this._update();
|
37
|
+
|
38
|
+
this.setOpacity(this.options.opacity);
|
39
|
+
|
40
|
+
map
|
41
|
+
.on('moveend', this._onMoveEnd, this)
|
42
|
+
.on('viewreset', this._onViewReset, this);
|
29
43
|
|
30
44
|
if (this._animated) {
|
31
45
|
map.on('zoomanim', this._zoomAnimation, this);
|
@@ -34,37 +48,47 @@ L.Label = L.Popup.extend({
|
|
34
48
|
if (L.Browser.touch && !this.options.noHide) {
|
35
49
|
L.DomEvent.on(this._container, 'click', this.close, this);
|
36
50
|
}
|
37
|
-
|
38
|
-
this._update();
|
39
|
-
|
40
|
-
this.setOpacity(this.options.opacity);
|
41
51
|
},
|
42
52
|
|
43
53
|
onRemove: function (map) {
|
44
54
|
this._pane.removeChild(this._container);
|
45
55
|
|
46
|
-
L.Util.falseFn(this._container.offsetWidth); // force reflow
|
47
|
-
|
48
56
|
map.off({
|
49
|
-
|
50
|
-
|
57
|
+
zoomanim: this._zoomAnimation,
|
58
|
+
moveend: this._onMoveEnd,
|
59
|
+
viewreset: this._onViewReset
|
51
60
|
}, this);
|
52
61
|
|
53
|
-
|
54
|
-
L.DomUtil.setOpacity(this._container, 0);
|
55
|
-
}
|
62
|
+
this._removeInteraction();
|
56
63
|
|
57
64
|
this._map = null;
|
58
65
|
},
|
59
66
|
|
67
|
+
setLatLng: function (latlng) {
|
68
|
+
this._latlng = L.latLng(latlng);
|
69
|
+
if (this._map) {
|
70
|
+
this._updatePosition();
|
71
|
+
}
|
72
|
+
return this;
|
73
|
+
},
|
74
|
+
|
75
|
+
setContent: function (content) {
|
76
|
+
// Backup previous content and store new content
|
77
|
+
this._previousContent = this._content;
|
78
|
+
this._content = content;
|
79
|
+
|
80
|
+
this._updateContent();
|
81
|
+
|
82
|
+
return this;
|
83
|
+
},
|
84
|
+
|
60
85
|
close: function () {
|
61
86
|
var map = this._map;
|
62
|
-
if (L.Browser.touch && !this.options.noHide) {
|
63
|
-
L.DomEvent.off(this._container, 'click', this.close);
|
64
|
-
}
|
65
87
|
|
66
88
|
if (map) {
|
67
|
-
|
89
|
+
if (L.Browser.touch && !this.options.noHide) {
|
90
|
+
L.DomEvent.off(this._container, 'click', this.close);
|
91
|
+
}
|
68
92
|
|
69
93
|
map.removeLayer(this);
|
70
94
|
}
|
@@ -73,7 +97,7 @@ L.Label = L.Popup.extend({
|
|
73
97
|
updateZIndex: function (zIndex) {
|
74
98
|
this._zIndex = zIndex;
|
75
99
|
|
76
|
-
if (this._container) {
|
100
|
+
if (this._container && this._zIndex) {
|
77
101
|
this._container.style.zIndex = zIndex;
|
78
102
|
}
|
79
103
|
},
|
@@ -91,16 +115,29 @@ L.Label = L.Popup.extend({
|
|
91
115
|
this.updateZIndex(this._zIndex);
|
92
116
|
},
|
93
117
|
|
118
|
+
_update: function () {
|
119
|
+
if (!this._map) { return; }
|
120
|
+
|
121
|
+
this._container.style.visibility = 'hidden';
|
122
|
+
|
123
|
+
this._updateContent();
|
124
|
+
this._updatePosition();
|
125
|
+
|
126
|
+
this._container.style.visibility = '';
|
127
|
+
},
|
128
|
+
|
94
129
|
_updateContent: function () {
|
95
|
-
if (!this._content) {
|
130
|
+
if (!this._content || !this._map || this._prevContent === this._content) {
|
131
|
+
return;
|
132
|
+
}
|
96
133
|
|
97
134
|
if (typeof this._content === 'string') {
|
98
135
|
this._container.innerHTML = this._content;
|
99
|
-
}
|
100
|
-
},
|
101
136
|
|
102
|
-
|
103
|
-
|
137
|
+
this._prevContent = this._content;
|
138
|
+
|
139
|
+
this._labelWidth = this._container.offsetWidth;
|
140
|
+
}
|
104
141
|
},
|
105
142
|
|
106
143
|
_updatePosition: function () {
|
@@ -110,14 +147,101 @@ L.Label = L.Popup.extend({
|
|
110
147
|
},
|
111
148
|
|
112
149
|
_setPosition: function (pos) {
|
113
|
-
|
150
|
+
var map = this._map,
|
151
|
+
container = this._container,
|
152
|
+
centerPoint = map.latLngToContainerPoint(map.getCenter()),
|
153
|
+
labelPoint = map.layerPointToContainerPoint(pos),
|
154
|
+
direction = this.options.direction,
|
155
|
+
labelWidth = this._labelWidth,
|
156
|
+
offset = L.point(this.options.offset);
|
157
|
+
|
158
|
+
// position to the right (right or auto & needs to)
|
159
|
+
if (direction === 'right' || direction === 'auto' && labelPoint.x < centerPoint.x) {
|
160
|
+
L.DomUtil.addClass(container, 'leaflet-label-right');
|
161
|
+
L.DomUtil.removeClass(container, 'leaflet-label-left');
|
162
|
+
|
163
|
+
pos = pos.add(offset);
|
164
|
+
} else { // position to the left
|
165
|
+
L.DomUtil.addClass(container, 'leaflet-label-left');
|
166
|
+
L.DomUtil.removeClass(container, 'leaflet-label-right');
|
167
|
+
|
168
|
+
pos = pos.add(L.point(-offset.x - labelWidth, offset.y));
|
169
|
+
}
|
114
170
|
|
115
|
-
L.DomUtil.setPosition(
|
171
|
+
L.DomUtil.setPosition(container, pos);
|
116
172
|
},
|
117
173
|
|
118
174
|
_zoomAnimation: function (opt) {
|
119
|
-
var pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center);
|
175
|
+
var pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center).round();
|
120
176
|
|
121
177
|
this._setPosition(pos);
|
178
|
+
},
|
179
|
+
|
180
|
+
_onMoveEnd: function () {
|
181
|
+
if (!this._animated || this.options.direction === 'auto') {
|
182
|
+
this._updatePosition();
|
183
|
+
}
|
184
|
+
},
|
185
|
+
|
186
|
+
_onViewReset: function (e) {
|
187
|
+
/* if map resets hard, we must update the label */
|
188
|
+
if (e && e.hard) {
|
189
|
+
this._update();
|
190
|
+
}
|
191
|
+
},
|
192
|
+
|
193
|
+
_initInteraction: function () {
|
194
|
+
if (!this.options.clickable) { return; }
|
195
|
+
|
196
|
+
var container = this._container,
|
197
|
+
events = ['dblclick', 'mousedown', 'mouseover', 'mouseout', 'contextmenu'];
|
198
|
+
|
199
|
+
L.DomUtil.addClass(container, 'leaflet-clickable');
|
200
|
+
L.DomEvent.on(container, 'click', this._onMouseClick, this);
|
201
|
+
|
202
|
+
for (var i = 0; i < events.length; i++) {
|
203
|
+
L.DomEvent.on(container, events[i], this._fireMouseEvent, this);
|
204
|
+
}
|
205
|
+
},
|
206
|
+
|
207
|
+
_removeInteraction: function () {
|
208
|
+
if (!this.options.clickable) { return; }
|
209
|
+
|
210
|
+
var container = this._container,
|
211
|
+
events = ['dblclick', 'mousedown', 'mouseover', 'mouseout', 'contextmenu'];
|
212
|
+
|
213
|
+
L.DomUtil.removeClass(container, 'leaflet-clickable');
|
214
|
+
L.DomEvent.off(container, 'click', this._onMouseClick, this);
|
215
|
+
|
216
|
+
for (var i = 0; i < events.length; i++) {
|
217
|
+
L.DomEvent.off(container, events[i], this._fireMouseEvent, this);
|
218
|
+
}
|
219
|
+
},
|
220
|
+
|
221
|
+
_onMouseClick: function (e) {
|
222
|
+
if (this.hasEventListeners(e.type)) {
|
223
|
+
L.DomEvent.stopPropagation(e);
|
224
|
+
}
|
225
|
+
|
226
|
+
this.fire(e.type, {
|
227
|
+
originalEvent: e
|
228
|
+
});
|
229
|
+
},
|
230
|
+
|
231
|
+
_fireMouseEvent: function (e) {
|
232
|
+
this.fire(e.type, {
|
233
|
+
originalEvent: e
|
234
|
+
});
|
235
|
+
|
236
|
+
// TODO proper custom event propagation
|
237
|
+
// this line will always be called if marker is in a FeatureGroup
|
238
|
+
if (e.type === 'contextmenu' && this.hasEventListeners(e.type)) {
|
239
|
+
L.DomEvent.preventDefault(e);
|
240
|
+
}
|
241
|
+
if (e.type !== 'mousedown') {
|
242
|
+
L.DomEvent.stopPropagation(e);
|
243
|
+
} else {
|
244
|
+
L.DomEvent.preventDefault(e);
|
245
|
+
}
|
122
246
|
}
|
123
|
-
});
|
247
|
+
});
|
@@ -9,123 +9,8 @@ L.Marker.mergeOptions({
|
|
9
9
|
icon: new L.Icon.Default()
|
10
10
|
});
|
11
11
|
|
12
|
+
L.Marker.include(L.BaseMarkerMethods);
|
12
13
|
L.Marker.include({
|
13
|
-
showLabel: function () {
|
14
|
-
if (this._label && this._map) {
|
15
|
-
this._label.setLatLng(this._latlng);
|
16
|
-
this._map.showLabel(this._label);
|
17
|
-
}
|
18
|
-
|
19
|
-
return this;
|
20
|
-
},
|
21
|
-
|
22
|
-
hideLabel: function () {
|
23
|
-
if (this._label) {
|
24
|
-
this._label.close();
|
25
|
-
}
|
26
|
-
return this;
|
27
|
-
},
|
28
|
-
|
29
|
-
setLabelNoHide: function (noHide) {
|
30
|
-
if (this._labelNoHide === noHide) {
|
31
|
-
return;
|
32
|
-
}
|
33
|
-
|
34
|
-
this._labelNoHide = noHide;
|
35
|
-
|
36
|
-
if (noHide) {
|
37
|
-
this._removeLabelRevealHandlers();
|
38
|
-
this.showLabel();
|
39
|
-
} else {
|
40
|
-
this._addLabelRevealHandlers();
|
41
|
-
this.hideLabel();
|
42
|
-
}
|
43
|
-
},
|
44
|
-
|
45
|
-
bindLabel: function (content, options) {
|
46
|
-
var anchor = L.point(this.options.icon.options.labelAnchor) || new L.Point(0, 0);
|
47
|
-
|
48
|
-
anchor = anchor.add(L.Label.prototype.options.offset);
|
49
|
-
|
50
|
-
if (options && options.offset) {
|
51
|
-
anchor = anchor.add(options.offset);
|
52
|
-
}
|
53
|
-
|
54
|
-
options = L.Util.extend({offset: anchor}, options);
|
55
|
-
|
56
|
-
this._labelNoHide = options.noHide;
|
57
|
-
|
58
|
-
if (!this._label) {
|
59
|
-
if (!this._labelNoHide) {
|
60
|
-
this._addLabelRevealHandlers();
|
61
|
-
}
|
62
|
-
|
63
|
-
this
|
64
|
-
.on('remove', this.hideLabel, this)
|
65
|
-
.on('move', this._moveLabel, this);
|
66
|
-
|
67
|
-
this._hasLabelHandlers = true;
|
68
|
-
}
|
69
|
-
|
70
|
-
this._label = new L.Label(options, this)
|
71
|
-
.setContent(content);
|
72
|
-
|
73
|
-
return this;
|
74
|
-
},
|
75
|
-
|
76
|
-
unbindLabel: function () {
|
77
|
-
if (this._label) {
|
78
|
-
this.hideLabel();
|
79
|
-
|
80
|
-
this._label = null;
|
81
|
-
|
82
|
-
if (this._hasLabelHandlers) {
|
83
|
-
if (!this._labelNoHide) {
|
84
|
-
this._removeLabelRevealHandlers();
|
85
|
-
}
|
86
|
-
|
87
|
-
this
|
88
|
-
.off('remove', this.hideLabel, this)
|
89
|
-
.off('move', this._moveLabel, this);
|
90
|
-
}
|
91
|
-
|
92
|
-
this._hasLabelHandlers = false;
|
93
|
-
}
|
94
|
-
return this;
|
95
|
-
},
|
96
|
-
|
97
|
-
updateLabelContent: function (content) {
|
98
|
-
if (this._label) {
|
99
|
-
this._label.setContent(content);
|
100
|
-
}
|
101
|
-
},
|
102
|
-
|
103
|
-
_addLabelRevealHandlers: function () {
|
104
|
-
this
|
105
|
-
.on('mouseover', this.showLabel, this)
|
106
|
-
.on('mouseout', this.hideLabel, this);
|
107
|
-
|
108
|
-
if (L.Browser.touch) {
|
109
|
-
this.on('click', this.showLabel, this);
|
110
|
-
}
|
111
|
-
},
|
112
|
-
|
113
|
-
_removeLabelRevealHandlers: function () {
|
114
|
-
this
|
115
|
-
.off('mouseover', this.showLabel, this)
|
116
|
-
.off('mouseout', this.hideLabel, this)
|
117
|
-
.off('remove', this.hideLabel, this)
|
118
|
-
.off('move', this._moveLabel, this);
|
119
|
-
|
120
|
-
if (L.Browser.touch) {
|
121
|
-
this.off('click', this.showLabel, this);
|
122
|
-
}
|
123
|
-
},
|
124
|
-
|
125
|
-
_moveLabel: function (e) {
|
126
|
-
this._label.setLatLng(e.latlng);
|
127
|
-
},
|
128
|
-
|
129
14
|
_originalUpdateZIndex: L.Marker.prototype._updateZIndex,
|
130
15
|
|
131
16
|
_updateZIndex: function (offset) {
|
@@ -133,8 +18,8 @@ L.Marker.include({
|
|
133
18
|
|
134
19
|
this._originalUpdateZIndex(offset);
|
135
20
|
|
136
|
-
if (this.
|
137
|
-
this.
|
21
|
+
if (this.label) {
|
22
|
+
this.label.updateZIndex(zIndex);
|
138
23
|
}
|
139
24
|
},
|
140
25
|
|
@@ -153,8 +38,18 @@ L.Marker.include({
|
|
153
38
|
|
154
39
|
this._originalUpdateOpacity();
|
155
40
|
|
156
|
-
if (this.
|
157
|
-
this.
|
41
|
+
if (this.label) {
|
42
|
+
this.label.setOpacity(this.options.labelHasSemiTransparency ? this.options.opacity : absoluteOpacity);
|
158
43
|
}
|
44
|
+
},
|
45
|
+
|
46
|
+
_originalSetLatLng: L.Marker.prototype.setLatLng,
|
47
|
+
|
48
|
+
setLatLng: function (latlng) {
|
49
|
+
if (this.label && !this._labelNoHide) {
|
50
|
+
this.hideLabel();
|
51
|
+
}
|
52
|
+
|
53
|
+
return this._originalSetLatLng(latlng);
|
159
54
|
}
|
160
55
|
});
|
@@ -1,10 +1,10 @@
|
|
1
1
|
L.Path.include({
|
2
2
|
bindLabel: function (content, options) {
|
3
|
-
if (!this.
|
4
|
-
this.
|
3
|
+
if (!this.label || this.label.options !== options) {
|
4
|
+
this.label = new L.Label(options, this);
|
5
5
|
}
|
6
6
|
|
7
|
-
this.
|
7
|
+
this.label.setContent(content);
|
8
8
|
|
9
9
|
if (!this._showLabelAdded) {
|
10
10
|
this
|
@@ -22,9 +22,9 @@ L.Path.include({
|
|
22
22
|
},
|
23
23
|
|
24
24
|
unbindLabel: function () {
|
25
|
-
if (this.
|
25
|
+
if (this.label) {
|
26
26
|
this._hideLabel();
|
27
|
-
this.
|
27
|
+
this.label = null;
|
28
28
|
this._showLabelAdded = false;
|
29
29
|
this
|
30
30
|
.off('mouseover', this._showLabel, this)
|
@@ -35,21 +35,21 @@ L.Path.include({
|
|
35
35
|
},
|
36
36
|
|
37
37
|
updateLabelContent: function (content) {
|
38
|
-
if (this.
|
39
|
-
this.
|
38
|
+
if (this.label) {
|
39
|
+
this.label.setContent(content);
|
40
40
|
}
|
41
41
|
},
|
42
42
|
|
43
43
|
_showLabel: function (e) {
|
44
|
-
this.
|
45
|
-
this._map.showLabel(this.
|
44
|
+
this.label.setLatLng(e.latlng);
|
45
|
+
this._map.showLabel(this.label);
|
46
46
|
},
|
47
47
|
|
48
48
|
_moveLabel: function (e) {
|
49
|
-
this.
|
49
|
+
this.label.setLatLng(e.latlng);
|
50
50
|
},
|
51
51
|
|
52
52
|
_hideLabel: function () {
|
53
|
-
this.
|
53
|
+
this.label.close();
|
54
54
|
}
|
55
55
|
});
|