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
@@ -4,24 +4,27 @@
|
|
4
4
|
|
5
5
|
L.Map.include({
|
6
6
|
|
7
|
-
setView: function (center, zoom,
|
7
|
+
setView: function (center, zoom, options) {
|
8
8
|
|
9
|
-
zoom = this._limitZoom(zoom);
|
10
|
-
center = L.latLng(center);
|
9
|
+
zoom = zoom === undefined ? this._zoom : this._limitZoom(zoom);
|
10
|
+
center = this._limitCenter(L.latLng(center), zoom, this.options.maxBounds);
|
11
|
+
options = options || {};
|
11
12
|
|
12
13
|
if (this._panAnim) {
|
13
14
|
this._panAnim.stop();
|
14
15
|
}
|
15
16
|
|
16
|
-
|
17
|
-
canBeAnimated = this._loaded && !forceReset && !!this._layers;
|
17
|
+
if (this._loaded && !options.reset && options !== true) {
|
18
18
|
|
19
|
-
|
19
|
+
if (options.animate !== undefined) {
|
20
|
+
options.zoom = L.extend({animate: options.animate}, options.zoom);
|
21
|
+
options.pan = L.extend({animate: options.animate}, options.pan);
|
22
|
+
}
|
20
23
|
|
21
24
|
// try animating pan or zoom
|
22
|
-
var animated =
|
23
|
-
this.
|
24
|
-
this.
|
25
|
+
var animated = (this._zoom !== zoom) ?
|
26
|
+
this._tryAnimatedZoom && this._tryAnimatedZoom(center, zoom, options.zoom) :
|
27
|
+
this._tryAnimatedPan(center, options.pan);
|
25
28
|
|
26
29
|
if (animated) {
|
27
30
|
// prevent resize handler call, the view will refresh after animation anyway
|
@@ -36,10 +39,9 @@ L.Map.include({
|
|
36
39
|
return this;
|
37
40
|
},
|
38
41
|
|
39
|
-
panBy: function (offset,
|
42
|
+
panBy: function (offset, options) {
|
40
43
|
offset = L.point(offset).round();
|
41
|
-
|
42
|
-
// TODO add options instead of arguments to setView/panTo/panBy/etc.
|
44
|
+
options = options || {};
|
43
45
|
|
44
46
|
if (!offset.x && !offset.y) {
|
45
47
|
return this;
|
@@ -55,14 +57,20 @@ L.Map.include({
|
|
55
57
|
}
|
56
58
|
|
57
59
|
// don't fire movestart if animating inertia
|
58
|
-
if (!noMoveStart) {
|
60
|
+
if (!options.noMoveStart) {
|
59
61
|
this.fire('movestart');
|
60
62
|
}
|
61
63
|
|
62
|
-
|
64
|
+
// animate pan unless animate: false specified
|
65
|
+
if (options.animate !== false) {
|
66
|
+
L.DomUtil.addClass(this._mapPane, 'leaflet-pan-anim');
|
63
67
|
|
64
|
-
|
65
|
-
|
68
|
+
var newPos = this._getMapPanePos().subtract(offset);
|
69
|
+
this._panAnim.run(this._mapPane, newPos, options.duration || 0.25, options.easeLinearity);
|
70
|
+
} else {
|
71
|
+
this._rawPanBy(offset);
|
72
|
+
this.fire('move').fire('moveend');
|
73
|
+
}
|
66
74
|
|
67
75
|
return this;
|
68
76
|
},
|
@@ -76,13 +84,15 @@ L.Map.include({
|
|
76
84
|
this.fire('moveend');
|
77
85
|
},
|
78
86
|
|
79
|
-
|
87
|
+
_tryAnimatedPan: function (center, options) {
|
80
88
|
// difference between the new and current centers in pixels
|
81
89
|
var offset = this._getCenterOffset(center)._floor();
|
82
90
|
|
83
|
-
|
91
|
+
// don't animate too far unless animate: true specified in options
|
92
|
+
if ((options && options.animate) !== true && !this.getSize().contains(offset)) { return false; }
|
93
|
+
|
94
|
+
this.panBy(offset, options);
|
84
95
|
|
85
|
-
this.panBy(offset);
|
86
96
|
return true;
|
87
97
|
}
|
88
98
|
});
|
@@ -3,17 +3,22 @@
|
|
3
3
|
*/
|
4
4
|
|
5
5
|
L.Map.mergeOptions({
|
6
|
-
zoomAnimation:
|
6
|
+
zoomAnimation: true,
|
7
7
|
zoomAnimationThreshold: 4
|
8
8
|
});
|
9
9
|
|
10
10
|
if (L.DomUtil.TRANSITION) {
|
11
11
|
|
12
12
|
L.Map.addInitHook(function () {
|
13
|
+
// don't animate on browsers without hardware-accelerated transitions or old Android/Opera
|
14
|
+
this._zoomAnimated = this.options.zoomAnimation && L.DomUtil.TRANSITION &&
|
15
|
+
L.Browser.any3d && !L.Browser.android23 && !L.Browser.mobileOpera;
|
16
|
+
|
13
17
|
// zoom transitions run with the same duration for all layers, so if one of transitionend events
|
14
18
|
// happens after starting zoom animation (propagating to the map pane), we know that it ended globally
|
15
|
-
|
16
|
-
|
19
|
+
if (this._zoomAnimated) {
|
20
|
+
L.DomEvent.on(this._mapPane, L.DomUtil.TRANSITION_END, this._catchTransitionEnd, this);
|
21
|
+
}
|
17
22
|
});
|
18
23
|
}
|
19
24
|
|
@@ -25,26 +30,33 @@ L.Map.include(!L.DomUtil.TRANSITION ? {} : {
|
|
25
30
|
}
|
26
31
|
},
|
27
32
|
|
28
|
-
|
33
|
+
_nothingToAnimate: function () {
|
34
|
+
return !this._container.getElementsByClassName('leaflet-zoom-animated').length;
|
35
|
+
},
|
36
|
+
|
37
|
+
_tryAnimatedZoom: function (center, zoom, options) {
|
29
38
|
|
30
39
|
if (this._animatingZoom) { return true; }
|
31
40
|
|
32
|
-
|
33
|
-
|
41
|
+
options = options || {};
|
42
|
+
|
43
|
+
// don't animate if disabled, not supported or zoom difference is too large
|
44
|
+
if (!this._zoomAnimated || options.animate === false || this._nothingToAnimate() ||
|
45
|
+
Math.abs(zoom - this._zoom) > this.options.zoomAnimationThreshold) { return false; }
|
34
46
|
|
35
47
|
// offset is the pixel coords of the zoom origin relative to the current center
|
36
48
|
var scale = this.getZoomScale(zoom),
|
37
49
|
offset = this._getCenterOffset(center)._divideBy(1 - 1 / scale),
|
38
50
|
origin = this._getCenterLayerPoint()._add(offset);
|
39
51
|
|
40
|
-
//
|
41
|
-
if (!this.getSize().contains(offset)) { return false; }
|
52
|
+
// don't animate if the zoom origin isn't within one screen from the current center, unless forced
|
53
|
+
if (options.animate !== true && !this.getSize().contains(offset)) { return false; }
|
42
54
|
|
43
55
|
this
|
44
56
|
.fire('movestart')
|
45
57
|
.fire('zoomstart');
|
46
58
|
|
47
|
-
this._animateZoom(center, zoom, origin, scale);
|
59
|
+
this._animateZoom(center, zoom, origin, scale, null, true);
|
48
60
|
|
49
61
|
return true;
|
50
62
|
},
|
@@ -81,11 +81,18 @@ L.Map.include({
|
|
81
81
|
this.setView(latlng, zoom);
|
82
82
|
}
|
83
83
|
|
84
|
-
var
|
84
|
+
var data = {
|
85
85
|
latlng: latlng,
|
86
|
-
bounds: bounds
|
87
|
-
|
86
|
+
bounds: bounds,
|
87
|
+
timestamp: pos.timestamp
|
88
|
+
};
|
89
|
+
|
90
|
+
for (var i in pos.coords) {
|
91
|
+
if (typeof pos.coords[i] === 'number') {
|
92
|
+
data[i] = pos.coords[i];
|
93
|
+
}
|
94
|
+
}
|
88
95
|
|
89
|
-
this.fire('locationfound',
|
96
|
+
this.fire('locationfound', data);
|
90
97
|
}
|
91
98
|
});
|
@@ -12,6 +12,7 @@ L.Map.BoxZoom = L.Handler.extend({
|
|
12
12
|
this._map = map;
|
13
13
|
this._container = map._container;
|
14
14
|
this._pane = map._panes.overlayPane;
|
15
|
+
this._moved = false;
|
15
16
|
},
|
16
17
|
|
17
18
|
addHooks: function () {
|
@@ -20,31 +21,39 @@ L.Map.BoxZoom = L.Handler.extend({
|
|
20
21
|
|
21
22
|
removeHooks: function () {
|
22
23
|
L.DomEvent.off(this._container, 'mousedown', this._onMouseDown);
|
24
|
+
this._moved = false;
|
25
|
+
},
|
26
|
+
|
27
|
+
moved: function () {
|
28
|
+
return this._moved;
|
23
29
|
},
|
24
30
|
|
25
31
|
_onMouseDown: function (e) {
|
32
|
+
this._moved = false;
|
33
|
+
|
26
34
|
if (!e.shiftKey || ((e.which !== 1) && (e.button !== 1))) { return false; }
|
27
35
|
|
28
36
|
L.DomUtil.disableTextSelection();
|
37
|
+
L.DomUtil.disableImageDrag();
|
29
38
|
|
30
39
|
this._startLayerPoint = this._map.mouseEventToLayerPoint(e);
|
31
40
|
|
32
|
-
this._box = L.DomUtil.create('div', 'leaflet-zoom-box', this._pane);
|
33
|
-
L.DomUtil.setPosition(this._box, this._startLayerPoint);
|
34
|
-
|
35
|
-
//TODO refactor: move cursor to styles
|
36
|
-
this._container.style.cursor = 'crosshair';
|
37
|
-
|
38
41
|
L.DomEvent
|
39
42
|
.on(document, 'mousemove', this._onMouseMove, this)
|
40
43
|
.on(document, 'mouseup', this._onMouseUp, this)
|
41
|
-
.on(document, 'keydown', this._onKeyDown, this)
|
42
|
-
.preventDefault(e);
|
43
|
-
|
44
|
-
this._map.fire('boxzoomstart');
|
44
|
+
.on(document, 'keydown', this._onKeyDown, this);
|
45
45
|
},
|
46
46
|
|
47
47
|
_onMouseMove: function (e) {
|
48
|
+
if (!this._moved) {
|
49
|
+
this._box = L.DomUtil.create('div', 'leaflet-zoom-box', this._pane);
|
50
|
+
L.DomUtil.setPosition(this._box, this._startLayerPoint);
|
51
|
+
|
52
|
+
//TODO refactor: move cursor to styles
|
53
|
+
this._container.style.cursor = 'crosshair';
|
54
|
+
this._map.fire('boxzoomstart');
|
55
|
+
}
|
56
|
+
|
48
57
|
var startPoint = this._startLayerPoint,
|
49
58
|
box = this._box,
|
50
59
|
|
@@ -57,16 +66,21 @@ L.Map.BoxZoom = L.Handler.extend({
|
|
57
66
|
|
58
67
|
L.DomUtil.setPosition(box, newPos);
|
59
68
|
|
69
|
+
this._moved = true;
|
70
|
+
|
60
71
|
// TODO refactor: remove hardcoded 4 pixels
|
61
72
|
box.style.width = (Math.max(0, Math.abs(offset.x) - 4)) + 'px';
|
62
73
|
box.style.height = (Math.max(0, Math.abs(offset.y) - 4)) + 'px';
|
63
74
|
},
|
64
75
|
|
65
76
|
_finish: function () {
|
66
|
-
|
67
|
-
|
77
|
+
if (this._moved) {
|
78
|
+
this._pane.removeChild(this._box);
|
79
|
+
this._container.style.cursor = '';
|
80
|
+
}
|
68
81
|
|
69
82
|
L.DomUtil.enableTextSelection();
|
83
|
+
L.DomUtil.enableImageDrag();
|
70
84
|
|
71
85
|
L.DomEvent
|
72
86
|
.off(document, 'mousemove', this._onMouseMove)
|
@@ -8,15 +8,22 @@ L.Map.mergeOptions({
|
|
8
8
|
|
9
9
|
L.Map.DoubleClickZoom = L.Handler.extend({
|
10
10
|
addHooks: function () {
|
11
|
-
this._map.on('dblclick', this._onDoubleClick);
|
11
|
+
this._map.on('dblclick', this._onDoubleClick, this);
|
12
12
|
},
|
13
13
|
|
14
14
|
removeHooks: function () {
|
15
|
-
this._map.off('dblclick', this._onDoubleClick);
|
15
|
+
this._map.off('dblclick', this._onDoubleClick, this);
|
16
16
|
},
|
17
17
|
|
18
18
|
_onDoubleClick: function (e) {
|
19
|
-
this.
|
19
|
+
var map = this._map,
|
20
|
+
zoom = map.getZoom() + (e.originalEvent.shiftKey ? -1 : 1);
|
21
|
+
|
22
|
+
if (map.options.doubleClickZoom === 'center') {
|
23
|
+
map.setZoom(zoom);
|
24
|
+
} else {
|
25
|
+
map.setZoomAround(e.containerPoint, zoom);
|
26
|
+
}
|
20
27
|
}
|
21
28
|
});
|
22
29
|
|
@@ -11,8 +11,6 @@ L.Map.mergeOptions({
|
|
11
11
|
inertiaThreshold: L.Browser.touch ? 32 : 18, // ms
|
12
12
|
easeLinearity: 0.25,
|
13
13
|
|
14
|
-
longPress: true,
|
15
|
-
|
16
14
|
// TODO refactor, move to CRS
|
17
15
|
worldCopyJump: false
|
18
16
|
});
|
@@ -22,7 +20,7 @@ L.Map.Drag = L.Handler.extend({
|
|
22
20
|
if (!this._draggable) {
|
23
21
|
var map = this._map;
|
24
22
|
|
25
|
-
this._draggable = new L.Draggable(map._mapPane, map._container
|
23
|
+
this._draggable = new L.Draggable(map._mapPane, map._container);
|
26
24
|
|
27
25
|
this._draggable.on({
|
28
26
|
'dragstart': this._onDragStart,
|
@@ -33,6 +31,8 @@ L.Map.Drag = L.Handler.extend({
|
|
33
31
|
if (map.options.worldCopyJump) {
|
34
32
|
this._draggable.on('predrag', this._onPreDrag, this);
|
35
33
|
map.on('viewreset', this._onViewReset, this);
|
34
|
+
|
35
|
+
map.whenReady(this._onViewReset, this);
|
36
36
|
}
|
37
37
|
}
|
38
38
|
this._draggable.enable();
|
@@ -104,14 +104,14 @@ L.Map.Drag = L.Handler.extend({
|
|
104
104
|
this._draggable._newPos.x = newX;
|
105
105
|
},
|
106
106
|
|
107
|
-
_onDragEnd: function () {
|
107
|
+
_onDragEnd: function (e) {
|
108
108
|
var map = this._map,
|
109
109
|
options = map.options,
|
110
110
|
delay = +new Date() - this._lastTime,
|
111
111
|
|
112
112
|
noInertia = !options.inertia || delay > options.inertiaThreshold || !this._positions[0];
|
113
113
|
|
114
|
-
map.fire('dragend');
|
114
|
+
map.fire('dragend', e);
|
115
115
|
|
116
116
|
if (noInertia) {
|
117
117
|
map.fire('moveend');
|
@@ -135,8 +135,14 @@ L.Map.Drag = L.Handler.extend({
|
|
135
135
|
map.fire('moveend');
|
136
136
|
|
137
137
|
} else {
|
138
|
+
offset = map._limitOffset(offset, map.options.maxBounds);
|
139
|
+
|
138
140
|
L.Util.requestAnimFrame(function () {
|
139
|
-
map.panBy(offset,
|
141
|
+
map.panBy(offset, {
|
142
|
+
duration: decelerationDuration,
|
143
|
+
easeLinearity: ease,
|
144
|
+
noMoveStart: true
|
145
|
+
});
|
140
146
|
});
|
141
147
|
}
|
142
148
|
}
|
@@ -15,7 +15,7 @@ L.Map.Keyboard = L.Handler.extend({
|
|
15
15
|
right: [39],
|
16
16
|
down: [40],
|
17
17
|
up: [38],
|
18
|
-
zoomIn: [187, 107, 61],
|
18
|
+
zoomIn: [187, 107, 61, 171],
|
19
19
|
zoomOut: [189, 109, 173]
|
20
20
|
},
|
21
21
|
|
@@ -65,7 +65,7 @@ L.Map.Keyboard = L.Handler.extend({
|
|
65
65
|
var body = document.body,
|
66
66
|
docEl = document.documentElement,
|
67
67
|
top = body.scrollTop || docEl.scrollTop,
|
68
|
-
left = body.
|
68
|
+
left = body.scrollLeft || docEl.scrollLeft;
|
69
69
|
|
70
70
|
this._map._container.focus();
|
71
71
|
|
@@ -127,6 +127,9 @@ L.Map.Keyboard = L.Handler.extend({
|
|
127
127
|
map = this._map;
|
128
128
|
|
129
129
|
if (key in this._panKeys) {
|
130
|
+
|
131
|
+
if (map._panAnim && map._panAnim._inProgress) { return; }
|
132
|
+
|
130
133
|
map.panBy(this._panKeys[key]);
|
131
134
|
|
132
135
|
if (map.options.maxBounds) {
|
@@ -9,11 +9,13 @@ L.Map.mergeOptions({
|
|
9
9
|
L.Map.ScrollWheelZoom = L.Handler.extend({
|
10
10
|
addHooks: function () {
|
11
11
|
L.DomEvent.on(this._map._container, 'mousewheel', this._onWheelScroll, this);
|
12
|
+
L.DomEvent.on(this._map._container, 'MozMousePixelScroll', L.DomEvent.preventDefault);
|
12
13
|
this._delta = 0;
|
13
14
|
},
|
14
15
|
|
15
16
|
removeHooks: function () {
|
16
17
|
L.DomEvent.off(this._map._container, 'mousewheel', this._onWheelScroll);
|
18
|
+
L.DomEvent.off(this._map._container, 'MozMousePixelScroll', L.DomEvent.preventDefault);
|
17
19
|
},
|
18
20
|
|
19
21
|
_onWheelScroll: function (e) {
|
@@ -49,7 +51,11 @@ L.Map.ScrollWheelZoom = L.Handler.extend({
|
|
49
51
|
|
50
52
|
if (!delta) { return; }
|
51
53
|
|
52
|
-
map.
|
54
|
+
if (map.options.scrollWheelZoom === 'center') {
|
55
|
+
map.setZoom(zoom + delta);
|
56
|
+
} else {
|
57
|
+
map.setZoomAround(this._lastMousePos, zoom + delta);
|
58
|
+
}
|
53
59
|
}
|
54
60
|
});
|
55
61
|
|
@@ -0,0 +1,107 @@
|
|
1
|
+
/*
|
2
|
+
* L.Map.Tap is used to enable mobile hacks like quick taps and long hold.
|
3
|
+
*/
|
4
|
+
|
5
|
+
L.Map.mergeOptions({
|
6
|
+
tap: true,
|
7
|
+
tapTolerance: 15
|
8
|
+
});
|
9
|
+
|
10
|
+
L.Map.Tap = L.Handler.extend({
|
11
|
+
addHooks: function () {
|
12
|
+
L.DomEvent.on(this._map._container, 'touchstart', this._onDown, this);
|
13
|
+
},
|
14
|
+
|
15
|
+
removeHooks: function () {
|
16
|
+
L.DomEvent.off(this._map._container, 'touchstart', this._onDown, this);
|
17
|
+
},
|
18
|
+
|
19
|
+
_onDown: function (e) {
|
20
|
+
if (!e.touches) { return; }
|
21
|
+
|
22
|
+
L.DomEvent.preventDefault(e);
|
23
|
+
|
24
|
+
this._fireClick = true;
|
25
|
+
|
26
|
+
// don't simulate click or track longpress if more than 1 touch
|
27
|
+
if (e.touches.length > 1) {
|
28
|
+
this._fireClick = false;
|
29
|
+
clearTimeout(this._holdTimeout);
|
30
|
+
return;
|
31
|
+
}
|
32
|
+
|
33
|
+
var first = e.touches[0],
|
34
|
+
el = first.target;
|
35
|
+
|
36
|
+
this._startPos = this._newPos = new L.Point(first.clientX, first.clientY);
|
37
|
+
|
38
|
+
// if touching a link, highlight it
|
39
|
+
if (el.tagName && el.tagName.toLowerCase() === 'a') {
|
40
|
+
L.DomUtil.addClass(el, 'leaflet-active');
|
41
|
+
}
|
42
|
+
|
43
|
+
// simulate long hold but setting a timeout
|
44
|
+
this._holdTimeout = setTimeout(L.bind(function () {
|
45
|
+
if (this._isTapValid()) {
|
46
|
+
this._fireClick = false;
|
47
|
+
this._onUp();
|
48
|
+
this._simulateEvent('contextmenu', first);
|
49
|
+
}
|
50
|
+
}, this), 1000);
|
51
|
+
|
52
|
+
L.DomEvent
|
53
|
+
.on(document, 'touchmove', this._onMove, this)
|
54
|
+
.on(document, 'touchend', this._onUp, this);
|
55
|
+
},
|
56
|
+
|
57
|
+
_onUp: function (e) {
|
58
|
+
clearTimeout(this._holdTimeout);
|
59
|
+
|
60
|
+
L.DomEvent
|
61
|
+
.off(document, 'touchmove', this._onMove, this)
|
62
|
+
.off(document, 'touchend', this._onUp, this);
|
63
|
+
|
64
|
+
if (this._fireClick && e && e.changedTouches) {
|
65
|
+
|
66
|
+
var first = e.changedTouches[0],
|
67
|
+
el = first.target;
|
68
|
+
|
69
|
+
if (el && el.tagName && el.tagName.toLowerCase() === 'a') {
|
70
|
+
L.DomUtil.removeClass(el, 'leaflet-active');
|
71
|
+
}
|
72
|
+
|
73
|
+
// simulate click if the touch didn't move too much
|
74
|
+
if (this._isTapValid()) {
|
75
|
+
this._simulateEvent('click', first);
|
76
|
+
}
|
77
|
+
}
|
78
|
+
},
|
79
|
+
|
80
|
+
_isTapValid: function () {
|
81
|
+
return this._newPos.distanceTo(this._startPos) <= this._map.options.tapTolerance;
|
82
|
+
},
|
83
|
+
|
84
|
+
_onMove: function (e) {
|
85
|
+
var first = e.touches[0];
|
86
|
+
this._newPos = new L.Point(first.clientX, first.clientY);
|
87
|
+
},
|
88
|
+
|
89
|
+
_simulateEvent: function (type, e) {
|
90
|
+
var simulatedEvent = document.createEvent('MouseEvents');
|
91
|
+
|
92
|
+
simulatedEvent._simulated = true;
|
93
|
+
e.target._simulatedClick = true;
|
94
|
+
|
95
|
+
simulatedEvent.initMouseEvent(
|
96
|
+
type, true, true, window, 1,
|
97
|
+
e.screenX, e.screenY,
|
98
|
+
e.clientX, e.clientY,
|
99
|
+
false, false, false, false, 0, null);
|
100
|
+
|
101
|
+
e.target.dispatchEvent(simulatedEvent);
|
102
|
+
}
|
103
|
+
});
|
104
|
+
|
105
|
+
if (L.Browser.touch && !L.Browser.pointer) {
|
106
|
+
L.Map.addInitHook('addHandler', 'tap', L.Map.Tap);
|
107
|
+
}
|