Merge branch 'master' into refactorvectors

This commit is contained in:
Vladimir Agafonkin 2012-10-31 13:43:31 +02:00
commit d5ea49e047
16 changed files with 236 additions and 91 deletions

View File

@ -26,15 +26,19 @@ An in-progress version being developed on the master branch.
* Improved markers and vectors click event so that it propagates to map if no one is listening to it (by [@danzel](https://github.com/danzel)). [#834](https://github.com/CloudMade/Leaflet/issues/834) [#1033](https://github.com/CloudMade/Leaflet/pull/1033)
* Added `Path` `unbindPopup` method.
* Added `Path` `remove` event.
* Added `Marker` `riseOnHover` and `riseOffset` options (for bringing markers to front on hover, disabled by default) (by [jacobtoye](https://github.com/jacobtoye)). [#914](https://github.com/CloudMade/Leaflet/pull/914) [#920](https://github.com/CloudMade/Leaflet/issues/920)
* Added `Marker` `move` and `remove` events.
* Added `Map` `whenReady` method (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1063](https://github.com/CloudMade/Leaflet/pull/1063)
* Added `Control.Layers` `baselayerchange` event (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1064](https://github.com/CloudMade/Leaflet/pull/1064)
* Improved `Control.Layers` to support HTML in layer names (by [@aparshin](https://github.com/aparshin)). [#1055](https://github.com/CloudMade/Leaflet/pull/1055) [#1099](https://github.com/CloudMade/Leaflet/issues/1099)
* Removed `Browser` `ua`, `ie`, `gecko`, `opera` properties (no longer needed).
* Added `CRS.Simple` to the list of built-in CRS. It was added earlier but not included in the build.
### Bugfixes
#### General bugfixes
* Fixed broken tiles and zooming in RTL layouts (by [@danzel](https://github.com/danzel)). [#1099](https://github.com/CloudMade/Leaflet/pull/1099) [#1095](https://github.com/CloudMade/Leaflet/issues/1095)
* Fixed a bug with pan animation where it jumped to its end position if you tried to drag the map.
* Fixed a bug with shift-clicking on a zoom button leading to unexpected result.
* Fixed a glitch with zooming in while panning animation is running.
@ -47,16 +51,21 @@ An in-progress version being developed on the master branch.
* Fixed a bug where middle marker wasn't removed after deleting 2 end nodes from a polyline (by [@Svad](https://github.com/Svad)). [#1022](https://github.com/CloudMade/Leaflet/issues/1022) [#1023](https://github.com/CloudMade/Leaflet/pull/1023)
* Fixed a bug where `Map` `load` event happened too late (after `moveend`, etc.) (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1027](https://github.com/CloudMade/Leaflet/pull/1027)
* Fixed `Circle` `getBounds` to return correct bounds and work without adding the circle to a map. [#1068](https://github.com/CloudMade/Leaflet/issues/1068)
* Fixed a bug where removing `Popup` on `viewreset` throwed an error (by [fnicollet](https://github.com/fnicollet) and [@danzel](https://github.com/danzel)). [#1098](https://github.com/CloudMade/Leaflet/pull/1098) [#1094](https://github.com/CloudMade/Leaflet/issues/1094)
* Fixed a bug where `TileLayer.Canvas` `drawTile` didn't receive tile zoom level in arguments.
#### Browser bugfixes
* Fixed a bug with **wonky zoom animation in IE10** (by [@danzel](https://github.com/danzel)). [#1007](https://github.com/CloudMade/Leaflet/pull/1007)
* Fixed a bug with **wonky zoom animation in Chrome 23+** (by [@danzel](https://github.com/danzel)). [#1060](https://github.com/CloudMade/Leaflet/pull/1060) [#1056](https://github.com/CloudMade/Leaflet/issues/1056)
* Fixed a bug where "Not implemented" error sometimes appeared in IE6-8 (by [@bryguy](https://github.com/bryguy) and [@lookfirst](https://github.com/lookfirst)). [#892](https://github.com/CloudMade/Leaflet/issues/892) [#893](https://github.com/CloudMade/Leaflet/pull/893)
* Fixed compatibility with SmoothWheel extension for Firefox (by [@waldir](https://github.com/waldir)). [#1011](https://github.com/CloudMade/Leaflet/pull/1011)
* Fixed a bug with incorrect box zoom opacity in IE6-7 (by [@jacobtoye](https://github.com/jacobtoye)). [#1072](https://githubcom/CloudMade/Leaflet/pull/1072)
* Fixed a bug with box zoom throwing a JS error in IE6-7 (by [@danzel](https://github.com/danzel)). [#1071](https://github.com/CloudMade/Leaflet/pull/1071)
## 0.4.5 (October 25, 2012)
* Fixed a bug with **wonky zoom animation in IE10** (by [@danzel](https://github.com/danzel)). [#1007](https://github.com/CloudMade/Leaflet/pull/1007)
* Fixed a bug with **wonky zoom animation in Chrome 23+** (by [@danzel](https://github.com/danzel)). [#1060](https://github.com/CloudMade/Leaflet/pull/1060) [#1056](https://github.com/CloudMade/Leaflet/issues/1056)
## 0.4.4 (August 7, 2012)
### Improvements

View File

@ -1,4 +1,4 @@
Copyright (c) 2010-2011, CloudMade, Vladimir Agafonkin
Copyright (c) 2012, CloudMade, Vladimir Agafonkin
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are

View File

@ -1,10 +1,10 @@
<img src="http://leaflet.cloudmade.com/docs/images/logo.png" alt="Leaflet" />
<img src="http://leafletjs.com/docs/images/logo.png" alt="Leaflet" />
Leaflet is a modern, lightweight open-source JavaScript library for mobile-friendly interactive maps, developed by [Vladimir Agafonkin](http://agafonkin.com/en) of [CloudMade](http://cloudmade.com) with a team of dedicated [contributors](https://github.com/CloudMade/Leaflet/graphs/contributors). Weighting just about 25kb of gzipped JS code, it still has all the [features](http://leaflet.cloudmade.com/features.html) most developers ever need for online maps, while providing a fast, pleasant user experience.
It is built from the ground up to work efficiently and smoothly on both desktop and mobile platforms like iOS and Android, taking advantage of HTML5 and CSS3 on modern browsers. The focus is on usability, performance, small size, [A-grade](http://developer.yahoo.com/yui/articles/gbs/) browser support, flexibility and [easy to use API](http://leaflet.cloudmade.com/reference.html) with convention over configuration. The OOP-based code of the library is designed to be modular, extensible and very easy to understand.
Check out the website for more information: [leaflet.cloudmade.com](http://leaflet.cloudmade.com)
Check out the website for more information: [leafletjs.com](http://leafletjs.com)
## Contributing to Leaflet
Let's make the best open-source library for maps that can possibly exist!

View File

@ -74,6 +74,6 @@ exports.getSizeDelta = function (newContent, oldContent) {
if (!oldContent) {
return 'new';
}
var delta = newContent.length - oldContent.length;
var delta = newContent.replace(/\r\n?/g, '\n').length - oldContent.replace(/\r\n?/g, '\n').length;
return (delta >= 0 ? '+' : '') + delta;
};

View File

@ -15,6 +15,7 @@ var deps = {
'geo/projection/Projection.SphericalMercator.js',
'geo/projection/Projection.LonLat.js',
'geo/crs/CRS.js',
'geo/crs/CRS.Simple.js',
'geo/crs/CRS.EPSG3857.js',
'geo/crs/CRS.EPSG4326.js',
'map/Map.js'],

139
dist/leaflet-src.js vendored
View File

@ -346,35 +346,40 @@ L.Mixin.Events.fire = L.Mixin.Events.fireEvent;
(function () {
var ua = navigator.userAgent.toLowerCase(),
ie = !!window.ActiveXObject,
var ie = !!window.ActiveXObject,
// http://tanalin.com/en/articles/ie-version-js/
ie6 = ie && !window.XMLHttpRequest,
ie7 = ie && !document.querySelector,
// terrible browser detection to work around Safari / iOS / Android browser bugs
// see TileLayer._addTile and debug/hacks/jitter.html
ua = navigator.userAgent.toLowerCase(),
webkit = ua.indexOf("webkit") !== -1,
gecko = ua.indexOf("gecko") !== -1,
//Terrible browser detection to work around a safari / iOS / android browser bug. See TileLayer._addTile and debug/hacks/jitter.html
chrome = ua.indexOf("chrome") !== -1,
opera = window.opera,
android = ua.indexOf("android") !== -1,
android23 = ua.search("android [23]") !== -1,
mobile = typeof orientation !== undefined + '' ? true : false,
mobile = typeof orientation !== undefined + '',
msTouch = (window.navigator && window.navigator.msPointerEnabled && window.navigator.msMaxTouchPoints),
retina = (('devicePixelRatio' in window && window.devicePixelRatio > 1) ||
('matchMedia' in window && window.matchMedia("(min-resolution:144dpi)").matches)),
doc = document.documentElement,
ie3d = ie && ('transition' in doc.style),
webkit3d = webkit && ('WebKitCSSMatrix' in window) && ('m11' in new window.WebKitCSSMatrix()),
gecko3d = gecko && ('MozPerspective' in doc.style),
opera3d = opera && ('OTransition' in doc.style),
webkit3d = ('WebKitCSSMatrix' in window) && ('m11' in new window.WebKitCSSMatrix()),
gecko3d = 'MozPerspective' in doc.style,
opera3d = 'OTransition' in doc.style,
any3d = !window.L_DISABLE_3D && (ie3d || webkit3d || gecko3d || opera3d);
msTouch = (window.navigator && window.navigator.msPointerEnabled && window.navigator.msMaxTouchPoints);
var touch = !window.L_NO_TOUCH && (function () {
var startName = 'ontouchstart';
// IE10+ (We simulate these into touch* events in L.DomEvent and L.DomEvent.MsTouch)
if (msTouch) {
return true;
}
// WebKit, etc
if (startName in doc) {
// IE10+ (We simulate these into touch* events in L.DomEvent and L.DomEvent.MsTouch) or WebKit, etc.
if (msTouch || (startName in doc)) {
return true;
}
@ -397,15 +402,12 @@ L.Mixin.Events.fire = L.Mixin.Events.fireEvent;
return supported;
}());
var retina = (('devicePixelRatio' in window && window.devicePixelRatio > 1) || ('matchMedia' in window && window.matchMedia("(min-resolution:144dpi)").matches));
L.Browser = {
ua: ua,
ie: ie,
ie6: ie6,
ie7: ie7,
webkit: webkit,
gecko: gecko,
opera: opera,
android: android,
android23: android23,
@ -415,18 +417,19 @@ L.Mixin.Events.fire = L.Mixin.Events.fireEvent;
webkit3d: webkit3d,
gecko3d: gecko3d,
opera3d: opera3d,
any3d: !window.L_DISABLE_3D && (ie3d || webkit3d || gecko3d || opera3d),
any3d: any3d,
mobile: mobile,
mobileWebkit: mobile && webkit,
mobileWebkit3d: mobile && webkit3d,
mobileOpera: mobile && opera,
mobileOpera: mobile && window.opera,
touch: touch,
msTouch: msTouch,
retina: retina
};
}());
@ -682,7 +685,7 @@ L.DomUtil = {
value = el.currentStyle[style];
}
if (!value || value === 'auto') {
if ((!value || value === 'auto') && document.defaultView) {
var css = document.defaultView.getComputedStyle(el, null);
value = css ? css[style] : null;
}
@ -696,10 +699,11 @@ L.DomUtil = {
left = 0,
el = element,
docBody = document.body,
pos;
pos,
ie7 = L.Browser.ie7;
do {
top += el.offsetTop || 0;
top += el.offsetTop || 0;
left += el.offsetLeft || 0;
pos = L.DomUtil.getStyle(el, 'position');
@ -722,12 +726,32 @@ L.DomUtil = {
top -= el.scrollTop || 0;
left -= el.scrollLeft || 0;
//Webkit (and ie <= 7) handles RTL scrollLeft different to everyone else
// https://code.google.com/p/closure-library/source/browse/trunk/closure/goog/style/bidi.js
if (!L.DomUtil.documentIsLtr() && (L.Browser.webkit || ie7)) {
left += el.scrollWidth - el.clientWidth;
//ie7 shows the scrollbar by default and provides clientWidth counting it, so we need to add it back in if it is visible
// Scrollbar is on the left as we are RTL
if (ie7 && L.DomUtil.getStyle(el, 'overflow-y') !== 'hidden' && L.DomUtil.getStyle(el, 'overflow') !== 'hidden') {
left += 17;
}
}
el = el.parentNode;
} while (el);
return new L.Point(left, top);
},
documentIsLtr: function () {
if (!L.DomUtil._docIsLtrCached) {
L.DomUtil._docIsLtrCached = true;
L.DomUtil._docIsLtr = L.DomUtil.getStyle(document.body, 'direction') === "ltr";
}
return L.DomUtil._docIsLtr;
},
create: function (tagName, className, container) {
var el = document.createElement(tagName);
@ -785,7 +809,7 @@ L.DomUtil = {
if ('opacity' in el.style) {
el.style.opacity = value;
} else if (L.Browser.ie) {
} else if ('filter' in el.style) {
var filter = false,
filterName = 'DXImageTransform.Microsoft.Alpha';
@ -1164,6 +1188,13 @@ L.CRS = {
L.CRS.Simple = L.Util.extend({}, L.CRS, {
projection: L.Projection.LonLat,
transformation: new L.Transformation(1, 0, 1, 0)
});
L.CRS.EPSG3857 = L.Util.extend({}, L.CRS, {
code: 'EPSG:3857',
@ -2555,7 +2586,7 @@ L.TileLayer.Canvas = L.TileLayer.extend({
},
_redrawTile: function (tile) {
this.drawTile(tile, tile._tilePoint, tile._zoom);
this.drawTile(tile, tile._tilePoint, this._map._zoom);
},
_createTileProto: function () {
@ -2572,19 +2603,18 @@ L.TileLayer.Canvas = L.TileLayer.extend({
return tile;
},
_loadTile: function (tile, tilePoint, zoom) {
_loadTile: function (tile, tilePoint) {
tile._layer = this;
tile._tilePoint = tilePoint;
tile._zoom = zoom;
this.drawTile(tile, tilePoint, zoom);
this._redrawTile(tile);
if (!this.options.async) {
this.tileDrawn(tile);
}
},
drawTile: function (tile, tilePoint, zoom) {
drawTile: function (tile, tilePoint) {
// override with rendering code
},
@ -2880,7 +2910,9 @@ L.Marker = L.Class.extend({
clickable: true,
draggable: false,
zIndexOffset: 0,
opacity: 1
opacity: 1,
riseOnHover: false,
riseOffset: 250
},
initialize: function (latlng, options) {
@ -2974,7 +3006,14 @@ L.Marker = L.Class.extend({
needOpacityUpdate = (this.options.opacity < 1);
L.DomUtil.addClass(this._icon, classToAdd);
if (options.riseOnHover) {
L.DomEvent
.on(this._icon, 'mouseover', this._bringToFront, this)
.on(this._icon, 'mouseout', this._resetZIndex, this);
}
}
if (!this._shadow) {
this._shadow = options.icon.createShadow();
@ -3000,6 +3039,12 @@ L.Marker = L.Class.extend({
_removeIcon: function () {
var panes = this._map._panes;
if (this.options.riseOnHover) {
L.DomEvent
.off(this._icon, 'mouseover', this._bringToFront)
.off(this._icon, 'mouseout', this._resetZIndex);
}
panes.markerPane.removeChild(this._icon);
if (this._shadow) {
@ -3016,7 +3061,13 @@ L.Marker = L.Class.extend({
L.DomUtil.setPosition(this._shadow, pos);
}
this._icon.style.zIndex = pos.y + this.options.zIndexOffset;
this._zIndex = pos.y + this.options.zIndexOffset;
this._resetZIndex();
},
_updateZIndex: function (offset) {
this._icon.style.zIndex = this._zIndex + offset;
},
_animateZoom: function (opt) {
@ -3081,6 +3132,14 @@ L.Marker = L.Class.extend({
if (this._shadow) {
L.DomUtil.setOpacity(this._shadow, this.options.opacity);
}
},
_bringToFront: function () {
this._updateZIndex(this.options.riseOffset);
},
_resetZIndex: function () {
this._updateZIndex(0);
}
});
@ -3319,6 +3378,8 @@ L.Popup = L.Class.extend({
},
_updatePosition: function () {
if (!this._map) { return; }
var pos = this._map.latLngToLayerPoint(this._latlng),
is3d = L.Browser.any3d,
offset = this.options.offset;
@ -3916,11 +3977,11 @@ L.Map.include({
_animatePathZoom: function (opt) {
var scale = this.getZoomScale(opt.zoom),
offset = this._getCenterOffset(opt.center).divideBy(1 - 1 / scale),
viewportPos = this.containerPointToLayerPoint(this.getSize().multiplyBy(-L.Path.CLIP_PADDING)),
origin = viewportPos.add(offset).round();
offset = this._getCenterOffset(opt.center),
translate = offset.multiplyBy(-scale)._add(this._pathViewport.min);
this._pathRoot.style[L.DomUtil.TRANSFORM] = L.DomUtil.getTranslateString((origin.multiplyBy(-1).add(L.DomUtil.getPosition(this._pathRoot)).multiplyBy(scale).add(origin))) + ' scale(' + scale + ') ';
this._pathRoot.style[L.DomUtil.TRANSFORM] =
L.DomUtil.getTranslateString(translate) + ' scale(' + scale + ') ';
this._pathZooming = true;
},

1
dist/leaflet.css vendored
View File

@ -14,6 +14,7 @@
.leaflet-image-layer,
.leaflet-layer { /* TODO optimize classes */
position: absolute;
left: 0;
}
.leaflet-container {
overflow: hidden;

2
dist/leaflet.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,33 +1,38 @@
(function () {
var ua = navigator.userAgent.toLowerCase(),
ie = !!window.ActiveXObject,
var ie = !!window.ActiveXObject,
// http://tanalin.com/en/articles/ie-version-js/
ie6 = ie && !window.XMLHttpRequest,
ie7 = ie && !document.querySelector,
// terrible browser detection to work around Safari / iOS / Android browser bugs
// see TileLayer._addTile and debug/hacks/jitter.html
ua = navigator.userAgent.toLowerCase(),
webkit = ua.indexOf("webkit") !== -1,
gecko = ua.indexOf("gecko") !== -1,
//Terrible browser detection to work around a safari / iOS / android browser bug. See TileLayer._addTile and debug/hacks/jitter.html
chrome = ua.indexOf("chrome") !== -1,
opera = window.opera,
android = ua.indexOf("android") !== -1,
android23 = ua.search("android [23]") !== -1,
mobile = typeof orientation !== undefined + '' ? true : false,
mobile = typeof orientation !== undefined + '',
msTouch = (window.navigator && window.navigator.msPointerEnabled && window.navigator.msMaxTouchPoints),
retina = (('devicePixelRatio' in window && window.devicePixelRatio > 1) ||
('matchMedia' in window && window.matchMedia("(min-resolution:144dpi)").matches)),
doc = document.documentElement,
ie3d = ie && ('transition' in doc.style),
webkit3d = webkit && ('WebKitCSSMatrix' in window) && ('m11' in new window.WebKitCSSMatrix()),
gecko3d = gecko && ('MozPerspective' in doc.style),
opera3d = opera && ('OTransition' in doc.style),
webkit3d = ('WebKitCSSMatrix' in window) && ('m11' in new window.WebKitCSSMatrix()),
gecko3d = 'MozPerspective' in doc.style,
opera3d = 'OTransition' in doc.style,
any3d = !window.L_DISABLE_3D && (ie3d || webkit3d || gecko3d || opera3d);
msTouch = (window.navigator && window.navigator.msPointerEnabled && window.navigator.msMaxTouchPoints);
var touch = !window.L_NO_TOUCH && (function () {
var startName = 'ontouchstart';
// IE10+ (We simulate these into touch* events in L.DomEvent and L.DomEvent.MsTouch)
if (msTouch) {
return true;
}
// WebKit, etc
if (startName in doc) {
// IE10+ (We simulate these into touch* events in L.DomEvent and L.DomEvent.MsTouch) or WebKit, etc.
if (msTouch || (startName in doc)) {
return true;
}
@ -50,15 +55,12 @@
return supported;
}());
var retina = (('devicePixelRatio' in window && window.devicePixelRatio > 1) || ('matchMedia' in window && window.matchMedia("(min-resolution:144dpi)").matches));
L.Browser = {
ua: ua,
ie: ie,
ie6: ie6,
ie7: ie7,
webkit: webkit,
gecko: gecko,
opera: opera,
android: android,
android23: android23,
@ -68,16 +70,17 @@
webkit3d: webkit3d,
gecko3d: gecko3d,
opera3d: opera3d,
any3d: !window.L_DISABLE_3D && (ie3d || webkit3d || gecko3d || opera3d),
any3d: any3d,
mobile: mobile,
mobileWebkit: mobile && webkit,
mobileWebkit3d: mobile && webkit3d,
mobileOpera: mobile && opera,
mobileOpera: mobile && window.opera,
touch: touch,
msTouch: msTouch,
retina: retina
};
}());

View File

@ -15,7 +15,7 @@ L.DomUtil = {
value = el.currentStyle[style];
}
if (!value || value === 'auto') {
if ((!value || value === 'auto') && document.defaultView) {
var css = document.defaultView.getComputedStyle(el, null);
value = css ? css[style] : null;
}
@ -29,10 +29,11 @@ L.DomUtil = {
left = 0,
el = element,
docBody = document.body,
pos;
pos,
ie7 = L.Browser.ie7;
do {
top += el.offsetTop || 0;
top += el.offsetTop || 0;
left += el.offsetLeft || 0;
pos = L.DomUtil.getStyle(el, 'position');
@ -55,12 +56,32 @@ L.DomUtil = {
top -= el.scrollTop || 0;
left -= el.scrollLeft || 0;
//Webkit (and ie <= 7) handles RTL scrollLeft different to everyone else
// https://code.google.com/p/closure-library/source/browse/trunk/closure/goog/style/bidi.js
if (!L.DomUtil.documentIsLtr() && (L.Browser.webkit || ie7)) {
left += el.scrollWidth - el.clientWidth;
//ie7 shows the scrollbar by default and provides clientWidth counting it, so we need to add it back in if it is visible
// Scrollbar is on the left as we are RTL
if (ie7 && L.DomUtil.getStyle(el, 'overflow-y') !== 'hidden' && L.DomUtil.getStyle(el, 'overflow') !== 'hidden') {
left += 17;
}
}
el = el.parentNode;
} while (el);
return new L.Point(left, top);
},
documentIsLtr: function () {
if (!L.DomUtil._docIsLtrCached) {
L.DomUtil._docIsLtrCached = true;
L.DomUtil._docIsLtr = L.DomUtil.getStyle(document.body, 'direction') === "ltr";
}
return L.DomUtil._docIsLtr;
},
create: function (tagName, className, container) {
var el = document.createElement(tagName);
@ -118,7 +139,7 @@ L.DomUtil = {
if ('opacity' in el.style) {
el.style.opacity = value;
} else if (L.Browser.ie) {
} else if ('filter' in el.style) {
var filter = false,
filterName = 'DXImageTransform.Microsoft.Alpha';

View File

@ -12,9 +12,10 @@ L.Draggable = L.Class.extend({
TAP_TOLERANCE: 15
},
initialize: function (element, dragStartTarget) {
initialize: function (element, dragStartTarget, longPress) {
this._element = element;
this._dragStartTarget = dragStartTarget || element;
this._longPress = longPress && !L.Browser.msTouch;
},
enable: function () {
@ -39,6 +40,7 @@ L.Draggable = L.Class.extend({
((e.which !== 1) && (e.button !== 1) && !e.touches)) { return; }
L.DomEvent.preventDefault(e);
L.DomEvent.stopPropagation(e);
if (L.Draggable._disabled) { return; }
@ -46,6 +48,7 @@ L.Draggable = L.Class.extend({
if (e.touches && e.touches.length > 1) {
this._simulateClick = false;
clearTimeout(this._longPressTimeout);
return;
}
@ -64,6 +67,19 @@ L.Draggable = L.Class.extend({
this._startPoint = new L.Point(first.clientX, first.clientY);
this._startPos = this._newPos = L.DomUtil.getPosition(this._element);
//Touch contextmenu event emulation
if (e.touches && e.touches.length === 1 && L.Browser.touch && this._longPress) {
this._longPressTimeout = setTimeout(L.Util.bind(function () {
var dist = (this._newPos && this._newPos.distanceTo(this._startPos)) || 0;
if (dist < L.Draggable.TAP_TOLERANCE) {
this._simulateClick = false;
this._onUp();
this._simulateEvent('contextmenu', first);
}
}, this), 1000);
}
L.DomEvent.on(document, L.Draggable.MOVE, this._onMove, this);
L.DomEvent.on(document, L.Draggable.END, this._onUp, this);
},
@ -106,6 +122,7 @@ L.Draggable = L.Class.extend({
_onUp: function (e) {
var simulateClickTouch;
clearTimeout(this._longPressTimeout);
if (this._simulateClick && e.changedTouches) {
var first = e.changedTouches[0],
el = first.target,

View File

@ -189,6 +189,8 @@ L.Popup = L.Class.extend({
},
_updatePosition: function () {
if (!this._map) { return; }
var pos = this._map.latLngToLayerPoint(this._latlng),
is3d = L.Browser.any3d,
offset = this.options.offset;

View File

@ -12,7 +12,9 @@ L.Marker = L.Class.extend({
clickable: true,
draggable: false,
zIndexOffset: 0,
opacity: 1
opacity: 1,
riseOnHover: false,
riseOffset: 250
},
initialize: function (latlng, options) {
@ -106,7 +108,14 @@ L.Marker = L.Class.extend({
needOpacityUpdate = (this.options.opacity < 1);
L.DomUtil.addClass(this._icon, classToAdd);
if (options.riseOnHover) {
L.DomEvent
.on(this._icon, 'mouseover', this._bringToFront, this)
.on(this._icon, 'mouseout', this._resetZIndex, this);
}
}
if (!this._shadow) {
this._shadow = options.icon.createShadow();
@ -132,6 +141,12 @@ L.Marker = L.Class.extend({
_removeIcon: function () {
var panes = this._map._panes;
if (this.options.riseOnHover) {
L.DomEvent
.off(this._icon, 'mouseover', this._bringToFront)
.off(this._icon, 'mouseout', this._resetZIndex);
}
panes.markerPane.removeChild(this._icon);
if (this._shadow) {
@ -148,7 +163,13 @@ L.Marker = L.Class.extend({
L.DomUtil.setPosition(this._shadow, pos);
}
this._icon.style.zIndex = pos.y + this.options.zIndexOffset;
this._zIndex = pos.y + this.options.zIndexOffset;
this._resetZIndex();
},
_updateZIndex: function (offset) {
this._icon.style.zIndex = this._zIndex + offset;
},
_animateZoom: function (opt) {
@ -213,6 +234,14 @@ L.Marker = L.Class.extend({
if (this._shadow) {
L.DomUtil.setOpacity(this._shadow, this.options.opacity);
}
},
_bringToFront: function () {
this._updateZIndex(this.options.riseOffset);
},
_resetZIndex: function () {
this._updateZIndex(0);
}
});

View File

@ -19,7 +19,7 @@ L.TileLayer.Canvas = L.TileLayer.extend({
},
_redrawTile: function (tile) {
this.drawTile(tile, tile._tilePoint, tile._zoom);
this.drawTile(tile, tile._tilePoint, this._map._zoom);
},
_createTileProto: function () {
@ -36,19 +36,18 @@ L.TileLayer.Canvas = L.TileLayer.extend({
return tile;
},
_loadTile: function (tile, tilePoint, zoom) {
_loadTile: function (tile, tilePoint) {
tile._layer = this;
tile._tilePoint = tilePoint;
tile._zoom = zoom;
this.drawTile(tile, tilePoint, zoom);
this._redrawTile(tile);
if (!this.options.async) {
this.tileDrawn(tile);
}
},
drawTile: function (tile, tilePoint, zoom) {
drawTile: function (tile, tilePoint) {
// override with rendering code
},

View File

@ -162,11 +162,11 @@ L.Map.include({
_animatePathZoom: function (opt) {
var scale = this.getZoomScale(opt.zoom),
offset = this._getCenterOffset(opt.center).divideBy(1 - 1 / scale),
viewportPos = this.containerPointToLayerPoint(this.getSize().multiplyBy(-L.Path.CLIP_PADDING)),
origin = viewportPos.add(offset).round();
offset = this._getCenterOffset(opt.center),
translate = offset.multiplyBy(-scale)._add(this._pathViewport.min);
this._pathRoot.style[L.DomUtil.TRANSFORM] = L.DomUtil.getTranslateString((origin.multiplyBy(-1).add(L.DomUtil.getPosition(this._pathRoot)).multiplyBy(scale).add(origin))) + ' scale(' + scale + ') ';
this._pathRoot.style[L.DomUtil.TRANSFORM] =
L.DomUtil.getTranslateString(translate) + ' scale(' + scale + ') ';
this._pathZooming = true;
},

View File

@ -10,6 +10,8 @@ L.Map.mergeOptions({
inertiaMaxSpeed: 6000, // px/s
inertiaThreshold: L.Browser.touch ? 32 : 18, // ms
longPress: true,
// TODO refactor, move to CRS
worldCopyJump: true
});
@ -17,7 +19,9 @@ L.Map.mergeOptions({
L.Map.Drag = L.Handler.extend({
addHooks: function () {
if (!this._draggable) {
this._draggable = new L.Draggable(this._map._mapPane, this._map._container);
var options = this._map.options;
this._draggable = new L.Draggable(this._map._mapPane, this._map._container, options.longPress);
this._draggable.on({
'dragstart': this._onDragStart,
@ -25,8 +29,6 @@ L.Map.Drag = L.Handler.extend({
'dragend': this._onDragEnd
}, this);
var options = this._map.options;
if (options.worldCopyJump) {
this._draggable.on('predrag', this._onPreDrag, this);
this._map.on('viewreset', this._onViewReset, this);