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
@@ -16,12 +16,14 @@ L.DivIcon = L.Icon.extend({
|
|
16
16
|
html: false
|
17
17
|
},
|
18
18
|
|
19
|
-
createIcon: function () {
|
20
|
-
var div = document.createElement('div'),
|
19
|
+
createIcon: function (oldIcon) {
|
20
|
+
var div = (oldIcon && oldIcon.tagName === 'DIV') ? oldIcon : document.createElement('div'),
|
21
21
|
options = this.options;
|
22
22
|
|
23
23
|
if (options.html !== false) {
|
24
24
|
div.innerHTML = options.html;
|
25
|
+
} else {
|
26
|
+
div.innerHTML = '';
|
25
27
|
}
|
26
28
|
|
27
29
|
if (options.bgPos) {
|
@@ -35,7 +35,7 @@ L.Icon.Default = L.Icon.extend({
|
|
35
35
|
|
36
36
|
L.Icon.Default.imagePath = (function () {
|
37
37
|
var scripts = document.getElementsByTagName('script'),
|
38
|
-
leafletRe =
|
38
|
+
leafletRe = /[\/^]leaflet[\-\._]?([\w\-\._]*)\.js\??/;
|
39
39
|
|
40
40
|
var i, len, src, matches, path;
|
41
41
|
|
@@ -10,7 +10,7 @@ L.Icon = L.Class.extend({
|
|
10
10
|
iconSize: (Point) (can be set through CSS)
|
11
11
|
iconAnchor: (Point) (centered by default, can be set in CSS with negative margins)
|
12
12
|
popupAnchor: (Point) (if not specified, popup opens in the anchor point)
|
13
|
-
shadowUrl: (
|
13
|
+
shadowUrl: (String) (no shadow by default)
|
14
14
|
shadowRetinaUrl: (String) (optional, used for retina devices if detected)
|
15
15
|
shadowSize: (Point)
|
16
16
|
shadowAnchor: (Point)
|
@@ -22,15 +22,15 @@ L.Icon = L.Class.extend({
|
|
22
22
|
L.setOptions(this, options);
|
23
23
|
},
|
24
24
|
|
25
|
-
createIcon: function () {
|
26
|
-
return this._createIcon('icon');
|
25
|
+
createIcon: function (oldIcon) {
|
26
|
+
return this._createIcon('icon', oldIcon);
|
27
27
|
},
|
28
28
|
|
29
|
-
createShadow: function () {
|
30
|
-
return this._createIcon('shadow');
|
29
|
+
createShadow: function (oldIcon) {
|
30
|
+
return this._createIcon('shadow', oldIcon);
|
31
31
|
},
|
32
32
|
|
33
|
-
_createIcon: function (name) {
|
33
|
+
_createIcon: function (name, oldIcon) {
|
34
34
|
var src = this._getIconUrl(name);
|
35
35
|
|
36
36
|
if (!src) {
|
@@ -40,7 +40,12 @@ L.Icon = L.Class.extend({
|
|
40
40
|
return null;
|
41
41
|
}
|
42
42
|
|
43
|
-
var img
|
43
|
+
var img;
|
44
|
+
if (!oldIcon || oldIcon.tagName !== 'IMG') {
|
45
|
+
img = this._createImg(src);
|
46
|
+
} else {
|
47
|
+
img = this._createImg(src, oldIcon);
|
48
|
+
}
|
44
49
|
this._setIconStyles(img, name);
|
45
50
|
|
46
51
|
return img;
|
@@ -74,17 +79,9 @@ L.Icon = L.Class.extend({
|
|
74
79
|
}
|
75
80
|
},
|
76
81
|
|
77
|
-
_createImg: function (src) {
|
78
|
-
|
79
|
-
|
80
|
-
if (!L.Browser.ie6) {
|
81
|
-
el = document.createElement('img');
|
82
|
-
el.src = src;
|
83
|
-
} else {
|
84
|
-
el = document.createElement('div');
|
85
|
-
el.style.filter =
|
86
|
-
'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + src + '")';
|
87
|
-
}
|
82
|
+
_createImg: function (src, el) {
|
83
|
+
el = el || document.createElement('img');
|
84
|
+
el.src = src;
|
88
85
|
return el;
|
89
86
|
},
|
90
87
|
|
@@ -18,15 +18,17 @@ L.Handler.MarkerDrag = L.Handler.extend({
|
|
18
18
|
.on('drag', this._onDrag, this)
|
19
19
|
.on('dragend', this._onDragEnd, this);
|
20
20
|
this._draggable.enable();
|
21
|
+
L.DomUtil.addClass(this._marker._icon, 'leaflet-marker-draggable');
|
21
22
|
},
|
22
23
|
|
23
24
|
removeHooks: function () {
|
24
25
|
this._draggable
|
25
|
-
.off('dragstart', this._onDragStart)
|
26
|
-
.off('drag', this._onDrag)
|
27
|
-
.off('dragend', this._onDragEnd);
|
26
|
+
.off('dragstart', this._onDragStart, this)
|
27
|
+
.off('drag', this._onDrag, this)
|
28
|
+
.off('dragend', this._onDragEnd, this);
|
28
29
|
|
29
30
|
this._draggable.disable();
|
31
|
+
L.DomUtil.removeClass(this._marker._icon, 'leaflet-marker-draggable');
|
30
32
|
},
|
31
33
|
|
32
34
|
moved: function () {
|
@@ -58,9 +60,9 @@ L.Handler.MarkerDrag = L.Handler.extend({
|
|
58
60
|
.fire('drag');
|
59
61
|
},
|
60
62
|
|
61
|
-
_onDragEnd: function () {
|
63
|
+
_onDragEnd: function (e) {
|
62
64
|
this._marker
|
63
65
|
.fire('moveend')
|
64
|
-
.fire('dragend');
|
66
|
+
.fire('dragend', e);
|
65
67
|
}
|
66
68
|
});
|
@@ -19,6 +19,17 @@ L.Marker.include({
|
|
19
19
|
return this;
|
20
20
|
},
|
21
21
|
|
22
|
+
togglePopup: function () {
|
23
|
+
if (this._popup) {
|
24
|
+
if (this._popup._isOpen) {
|
25
|
+
this.closePopup();
|
26
|
+
} else {
|
27
|
+
this.openPopup();
|
28
|
+
}
|
29
|
+
}
|
30
|
+
return this;
|
31
|
+
},
|
32
|
+
|
22
33
|
bindPopup: function (content, options) {
|
23
34
|
var anchor = L.point(this.options.icon.options.popupAnchor || [0, 0]);
|
24
35
|
|
@@ -30,11 +41,12 @@ L.Marker.include({
|
|
30
41
|
|
31
42
|
options = L.extend({offset: anchor}, options);
|
32
43
|
|
33
|
-
if (!this.
|
44
|
+
if (!this._popupHandlersAdded) {
|
34
45
|
this
|
35
|
-
.on('click', this.
|
46
|
+
.on('click', this.togglePopup, this)
|
36
47
|
.on('remove', this.closePopup, this)
|
37
48
|
.on('move', this._movePopup, this);
|
49
|
+
this._popupHandlersAdded = true;
|
38
50
|
}
|
39
51
|
|
40
52
|
if (content instanceof L.Popup) {
|
@@ -59,13 +71,18 @@ L.Marker.include({
|
|
59
71
|
if (this._popup) {
|
60
72
|
this._popup = null;
|
61
73
|
this
|
62
|
-
.off('click', this.
|
63
|
-
.off('remove', this.closePopup)
|
64
|
-
.off('move', this._movePopup);
|
74
|
+
.off('click', this.togglePopup, this)
|
75
|
+
.off('remove', this.closePopup, this)
|
76
|
+
.off('move', this._movePopup, this);
|
77
|
+
this._popupHandlersAdded = false;
|
65
78
|
}
|
66
79
|
return this;
|
67
80
|
},
|
68
81
|
|
82
|
+
getPopup: function () {
|
83
|
+
return this._popup;
|
84
|
+
},
|
85
|
+
|
69
86
|
_movePopup: function (e) {
|
70
87
|
this._popup.setLatLng(e.latlng);
|
71
88
|
}
|
@@ -9,8 +9,10 @@ L.Marker = L.Class.extend({
|
|
9
9
|
options: {
|
10
10
|
icon: new L.Icon.Default(),
|
11
11
|
title: '',
|
12
|
+
alt: '',
|
12
13
|
clickable: true,
|
13
14
|
draggable: false,
|
15
|
+
keyboard: true,
|
14
16
|
zIndexOffset: 0,
|
15
17
|
opacity: 1,
|
16
18
|
riseOnHover: false,
|
@@ -29,6 +31,7 @@ L.Marker = L.Class.extend({
|
|
29
31
|
|
30
32
|
this._initIcon();
|
31
33
|
this.update();
|
34
|
+
this.fire('add');
|
32
35
|
|
33
36
|
if (map.options.zoomAnimation && map.options.markerZoomAnimation) {
|
34
37
|
map.on('zoomanim', this._animateZoom, this);
|
@@ -46,6 +49,7 @@ L.Marker = L.Class.extend({
|
|
46
49
|
}
|
47
50
|
|
48
51
|
this._removeIcon();
|
52
|
+
this._removeShadow();
|
49
53
|
|
50
54
|
this.fire('remove');
|
51
55
|
|
@@ -77,9 +81,6 @@ L.Marker = L.Class.extend({
|
|
77
81
|
},
|
78
82
|
|
79
83
|
setIcon: function (icon) {
|
80
|
-
if (this._map) {
|
81
|
-
this._removeIcon();
|
82
|
-
}
|
83
84
|
|
84
85
|
this.options.icon = icon;
|
85
86
|
|
@@ -88,6 +89,10 @@ L.Marker = L.Class.extend({
|
|
88
89
|
this.update();
|
89
90
|
}
|
90
91
|
|
92
|
+
if (this._popup) {
|
93
|
+
this.bindPopup(this._popup);
|
94
|
+
}
|
95
|
+
|
91
96
|
return this;
|
92
97
|
},
|
93
98
|
|
@@ -104,66 +109,90 @@ L.Marker = L.Class.extend({
|
|
104
109
|
var options = this.options,
|
105
110
|
map = this._map,
|
106
111
|
animation = (map.options.zoomAnimation && map.options.markerZoomAnimation),
|
107
|
-
classToAdd = animation ? 'leaflet-zoom-animated' : 'leaflet-zoom-hide'
|
108
|
-
needOpacityUpdate = false;
|
112
|
+
classToAdd = animation ? 'leaflet-zoom-animated' : 'leaflet-zoom-hide';
|
109
113
|
|
110
|
-
|
111
|
-
|
114
|
+
var icon = options.icon.createIcon(this._icon),
|
115
|
+
addIcon = false;
|
116
|
+
|
117
|
+
// if we're not reusing the icon, remove the old one and init new one
|
118
|
+
if (icon !== this._icon) {
|
119
|
+
if (this._icon) {
|
120
|
+
this._removeIcon();
|
121
|
+
}
|
122
|
+
addIcon = true;
|
112
123
|
|
113
124
|
if (options.title) {
|
114
|
-
|
125
|
+
icon.title = options.title;
|
115
126
|
}
|
127
|
+
|
128
|
+
if (options.alt) {
|
129
|
+
icon.alt = options.alt;
|
130
|
+
}
|
131
|
+
}
|
116
132
|
|
117
|
-
|
118
|
-
needOpacityUpdate = (this.options.opacity < 1);
|
133
|
+
L.DomUtil.addClass(icon, classToAdd);
|
119
134
|
|
120
|
-
|
135
|
+
if (options.keyboard) {
|
136
|
+
icon.tabIndex = '0';
|
137
|
+
}
|
121
138
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
139
|
+
this._icon = icon;
|
140
|
+
|
141
|
+
this._initInteraction();
|
142
|
+
|
143
|
+
if (options.riseOnHover) {
|
144
|
+
L.DomEvent
|
145
|
+
.on(icon, 'mouseover', this._bringToFront, this)
|
146
|
+
.on(icon, 'mouseout', this._resetZIndex, this);
|
127
147
|
}
|
128
148
|
|
129
|
-
|
130
|
-
|
149
|
+
var newShadow = options.icon.createShadow(this._shadow),
|
150
|
+
addShadow = false;
|
131
151
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
152
|
+
if (newShadow !== this._shadow) {
|
153
|
+
this._removeShadow();
|
154
|
+
addShadow = true;
|
155
|
+
}
|
156
|
+
|
157
|
+
if (newShadow) {
|
158
|
+
L.DomUtil.addClass(newShadow, classToAdd);
|
136
159
|
}
|
160
|
+
this._shadow = newShadow;
|
137
161
|
|
138
|
-
|
162
|
+
|
163
|
+
if (options.opacity < 1) {
|
139
164
|
this._updateOpacity();
|
140
165
|
}
|
141
166
|
|
167
|
+
|
142
168
|
var panes = this._map._panes;
|
143
169
|
|
144
|
-
|
170
|
+
if (addIcon) {
|
171
|
+
panes.markerPane.appendChild(this._icon);
|
172
|
+
}
|
145
173
|
|
146
|
-
if (
|
174
|
+
if (newShadow && addShadow) {
|
147
175
|
panes.shadowPane.appendChild(this._shadow);
|
148
176
|
}
|
149
177
|
},
|
150
178
|
|
151
179
|
_removeIcon: function () {
|
152
|
-
var panes = this._map._panes;
|
153
|
-
|
154
180
|
if (this.options.riseOnHover) {
|
155
181
|
L.DomEvent
|
156
182
|
.off(this._icon, 'mouseover', this._bringToFront)
|
157
183
|
.off(this._icon, 'mouseout', this._resetZIndex);
|
158
184
|
}
|
159
185
|
|
160
|
-
|
186
|
+
this._map._panes.markerPane.removeChild(this._icon);
|
187
|
+
|
188
|
+
this._icon = null;
|
189
|
+
},
|
161
190
|
|
191
|
+
_removeShadow: function () {
|
162
192
|
if (this._shadow) {
|
163
|
-
|
193
|
+
this._map._panes.shadowPane.removeChild(this._shadow);
|
164
194
|
}
|
165
|
-
|
166
|
-
this._icon = this._shadow = null;
|
195
|
+
this._shadow = null;
|
167
196
|
},
|
168
197
|
|
169
198
|
_setPos: function (pos) {
|
@@ -183,7 +212,7 @@ L.Marker = L.Class.extend({
|
|
183
212
|
},
|
184
213
|
|
185
214
|
_animateZoom: function (opt) {
|
186
|
-
var pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center);
|
215
|
+
var pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center).round();
|
187
216
|
|
188
217
|
this._setPos(pos);
|
189
218
|
},
|
@@ -199,6 +228,7 @@ L.Marker = L.Class.extend({
|
|
199
228
|
|
200
229
|
L.DomUtil.addClass(icon, 'leaflet-clickable');
|
201
230
|
L.DomEvent.on(icon, 'click', this._onMouseClick, this);
|
231
|
+
L.DomEvent.on(icon, 'keypress', this._onKeyPress, this);
|
202
232
|
|
203
233
|
for (var i = 0; i < events.length; i++) {
|
204
234
|
L.DomEvent.on(icon, events[i], this._fireMouseEvent, this);
|
@@ -230,6 +260,15 @@ L.Marker = L.Class.extend({
|
|
230
260
|
});
|
231
261
|
},
|
232
262
|
|
263
|
+
_onKeyPress: function (e) {
|
264
|
+
if (e.keyCode === 13) {
|
265
|
+
this.fire('click', {
|
266
|
+
originalEvent: e,
|
267
|
+
latlng: this._latlng
|
268
|
+
});
|
269
|
+
}
|
270
|
+
},
|
271
|
+
|
233
272
|
_fireMouseEvent: function (e) {
|
234
273
|
|
235
274
|
this.fire(e.type, {
|
@@ -244,6 +283,8 @@ L.Marker = L.Class.extend({
|
|
244
283
|
}
|
245
284
|
if (e.type !== 'mousedown') {
|
246
285
|
L.DomEvent.stopPropagation(e);
|
286
|
+
} else {
|
287
|
+
L.DomEvent.preventDefault(e);
|
247
288
|
}
|
248
289
|
},
|
249
290
|
|
@@ -252,6 +293,8 @@ L.Marker = L.Class.extend({
|
|
252
293
|
if (this._map) {
|
253
294
|
this._updateOpacity();
|
254
295
|
}
|
296
|
+
|
297
|
+
return this;
|
255
298
|
},
|
256
299
|
|
257
300
|
_updateOpacity: function () {
|
@@ -4,34 +4,19 @@
|
|
4
4
|
|
5
5
|
L.TileLayer.include({
|
6
6
|
_animateZoom: function (e) {
|
7
|
-
var firstFrame = false;
|
8
|
-
|
9
7
|
if (!this._animating) {
|
10
8
|
this._animating = true;
|
11
|
-
firstFrame = true;
|
12
|
-
}
|
13
|
-
|
14
|
-
if (firstFrame) {
|
15
9
|
this._prepareBgBuffer();
|
16
10
|
}
|
17
11
|
|
18
|
-
var
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
//prevent bg buffer from clearing right after zoom
|
23
|
-
clearTimeout(this._clearBgBufferTimer);
|
24
|
-
|
25
|
-
// hack to make sure transform is updated before running animation
|
26
|
-
L.Util.falseFn(bg.offsetWidth);
|
27
|
-
}
|
28
|
-
|
29
|
-
var scaleStr = L.DomUtil.getScaleString(e.scale, e.origin),
|
30
|
-
oldTransform = bg.style[transform];
|
12
|
+
var bg = this._bgBuffer,
|
13
|
+
transform = L.DomUtil.TRANSFORM,
|
14
|
+
initialTransform = e.delta ? L.DomUtil.getTranslateString(e.delta) : bg.style[transform],
|
15
|
+
scaleStr = L.DomUtil.getScaleString(e.scale, e.origin);
|
31
16
|
|
32
17
|
bg.style[transform] = e.backwards ?
|
33
|
-
|
34
|
-
|
18
|
+
scaleStr + ' ' + initialTransform :
|
19
|
+
initialTransform + ' ' + scaleStr;
|
35
20
|
},
|
36
21
|
|
37
22
|
_endZoomAnim: function () {
|
@@ -39,9 +24,7 @@ L.TileLayer.include({
|
|
39
24
|
bg = this._bgBuffer;
|
40
25
|
|
41
26
|
front.style.visibility = '';
|
42
|
-
front.
|
43
|
-
|
44
|
-
bg.style.zIndex = 1;
|
27
|
+
front.parentNode.appendChild(front); // Bring to fore
|
45
28
|
|
46
29
|
// force reflow
|
47
30
|
L.Util.falseFn(bg.offsetWidth);
|
@@ -66,8 +49,10 @@ L.TileLayer.include({
|
|
66
49
|
// if foreground layer doesn't have many tiles but bg layer does,
|
67
50
|
// keep the existing bg layer and just zoom it some more
|
68
51
|
|
69
|
-
|
70
|
-
|
52
|
+
var bgLoaded = this._getLoadedTilesPercentage(bg),
|
53
|
+
frontLoaded = this._getLoadedTilesPercentage(front);
|
54
|
+
|
55
|
+
if (bg && bgLoaded > 0.5 && frontLoaded < 0.5) {
|
71
56
|
|
72
57
|
front.style.visibility = 'hidden';
|
73
58
|
this._stopLoadingImages(front);
|
@@ -83,6 +68,9 @@ L.TileLayer.include({
|
|
83
68
|
bg = this._bgBuffer = front;
|
84
69
|
|
85
70
|
this._stopLoadingImages(bg);
|
71
|
+
|
72
|
+
//prevent bg buffer from clearing right after zoom
|
73
|
+
clearTimeout(this._clearBgBufferTimer);
|
86
74
|
},
|
87
75
|
|
88
76
|
_getLoadedTilesPercentage: function (container) {
|