From c7e29b5a875583b2501238b27b12fef3546d5ece Mon Sep 17 00:00:00 2001 From: Mithgol the Webmaster Date: Fri, 16 Mar 2012 09:44:07 +0400 Subject: [PATCH 01/23] detecting retina displays, adjusting tileSize --- src/layer/tile/TileLayer.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/layer/tile/TileLayer.js b/src/layer/tile/TileLayer.js index 76e66b32..e14897d0 100644 --- a/src/layer/tile/TileLayer.js +++ b/src/layer/tile/TileLayer.js @@ -27,6 +27,13 @@ L.TileLayer = L.Class.extend({ initialize: function (url, options) { L.Util.setOptions(this, options); + // detecting retina displays, adjusting tileSize + if (typeof window.devicePixelRatio != 'undefined') { + if (window.devicePixelRatio > 1) { + this.options.tileSize >>= 1; + } + } + this._url = url; var subdomains = this.options.subdomains; From 97cd41e9f5d58cee06c20f5ec1d0399ccc24226e Mon Sep 17 00:00:00 2001 From: Mithgol the Webmaster Date: Fri, 16 Mar 2012 10:53:54 +0400 Subject: [PATCH 02/23] correction: window.devicePixelRatio > 1 becomes false even if devicePixelRatio is undefined --- src/layer/tile/TileLayer.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/layer/tile/TileLayer.js b/src/layer/tile/TileLayer.js index e14897d0..41bca608 100644 --- a/src/layer/tile/TileLayer.js +++ b/src/layer/tile/TileLayer.js @@ -28,10 +28,8 @@ L.TileLayer = L.Class.extend({ L.Util.setOptions(this, options); // detecting retina displays, adjusting tileSize - if (typeof window.devicePixelRatio != 'undefined') { - if (window.devicePixelRatio > 1) { - this.options.tileSize >>= 1; - } + if (window.devicePixelRatio > 1) { + this.options.tileSize >>= 1; } this._url = url; From 7a9b504e754e439888d8a0296f17542dfd5cd949 Mon Sep 17 00:00:00 2001 From: Johannes Date: Sat, 17 Mar 2012 16:57:47 +0000 Subject: [PATCH 03/23] Fix bug in bind causing loss of arguments Empty Arrays are truthy Fixes issue #574 --- src/core/Util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/Util.js b/src/core/Util.js index 03fa4191..db26c90e 100644 --- a/src/core/Util.js +++ b/src/core/Util.js @@ -17,7 +17,7 @@ L.Util = { }, bind: function (fn, obj) { // (Function, Object) -> Function - var args = Array.prototype.slice.call(arguments, 2); + var args = arguments.length > 2 ? Array.prototype.slice.call(arguments, 2) : null; return function () { return fn.apply(obj, args || arguments); }; From c95945582eb170e7805e83541458331f6d5e0469 Mon Sep 17 00:00:00 2001 From: Johannes Date: Sat, 17 Mar 2012 19:19:56 +0000 Subject: [PATCH 04/23] Add basic geolocation debug page --- debug/map/geolocation.html | 45 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 debug/map/geolocation.html diff --git a/debug/map/geolocation.html b/debug/map/geolocation.html new file mode 100644 index 00000000..59221d92 --- /dev/null +++ b/debug/map/geolocation.html @@ -0,0 +1,45 @@ + + + + Leaflet geolocation debug page + + + + + + + + + + + + +
+ + + + From 7c0b9f06b8e85f9cc4015cf84c721b2a7cf88b15 Mon Sep 17 00:00:00 2001 From: Johannes Date: Mon, 19 Mar 2012 04:29:17 +0000 Subject: [PATCH 05/23] Clean up commented lines --- debug/map/geolocation.html | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/debug/map/geolocation.html b/debug/map/geolocation.html index 59221d92..7f5b0846 100644 --- a/debug/map/geolocation.html +++ b/debug/map/geolocation.html @@ -30,16 +30,6 @@ map.locate({setView: true}); - -// function logEvent(e) { console.log(e); } -// -// map.on('movestart', logEvent); -// map.on('move', logEvent); -// map.on('moveend', logEvent); -// -// map.on('zoomstart', logEvent); -// map.on('zoomend', logEvent); - From ab936cbafbd22ce59ec53a803291dfd91a006b7e Mon Sep 17 00:00:00 2001 From: Damon Oehlman Date: Mon, 26 Mar 2012 14:53:05 +1000 Subject: [PATCH 06/23] Tweaked DOM util opacity to only apply in IE when opacity !== 1 --- src/dom/DomUtil.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dom/DomUtil.js b/src/dom/DomUtil.js index 56a4ec1b..9127d8ee 100644 --- a/src/dom/DomUtil.js +++ b/src/dom/DomUtil.js @@ -98,7 +98,7 @@ L.DomUtil = { setOpacity: function (el, value) { if (L.Browser.ie) { - el.style.filter = 'alpha(opacity=' + Math.round(value * 100) + ')'; + el.style.filter = value !== 1 ? 'alpha(opacity=' + Math.round(value * 100) + ')' : ''; } else { el.style.opacity = value; } From 280649bf42230c4435a1fa54277422101dcda4f7 Mon Sep 17 00:00:00 2001 From: chx007 Date: Mon, 26 Mar 2012 22:04:57 +0800 Subject: [PATCH 07/23] getViewportOffset -> position:fiexd --- src/dom/DomUtil.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/dom/DomUtil.js b/src/dom/DomUtil.js index 56a4ec1b..8b23f3f3 100644 --- a/src/dom/DomUtil.js +++ b/src/dom/DomUtil.js @@ -33,6 +33,12 @@ L.DomUtil = { L.DomUtil.getStyle(el, 'position') === 'absolute') { break; } + if ( L.DomUtil.getStyle(el, 'position') === 'fixed'){ + top += docBody.scrollTop || 0; + left += docBody.scrollLeft || 0; + break; + } + el = el.offsetParent; } while (el); From 443181af07391cd624f6328ffd9d0e30351642bf Mon Sep 17 00:00:00 2001 From: Mithgol the Webmaster Date: Mon, 26 Mar 2012 19:57:12 +0400 Subject: [PATCH 08/23] detectRetina is optional (false by default) to prevent map features (like city titles) from being too small to read on retinal tiles --- src/layer/tile/TileLayer.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/layer/tile/TileLayer.js b/src/layer/tile/TileLayer.js index 41bca608..8992d34d 100644 --- a/src/layer/tile/TileLayer.js +++ b/src/layer/tile/TileLayer.js @@ -18,6 +18,7 @@ L.TileLayer = L.Class.extend({ noWrap: false, zoomOffset: 0, zoomReverse: false, + detectRetina: false, unloadInvisibleTiles: L.Browser.mobile, updateWhenIdle: L.Browser.mobile, @@ -28,7 +29,7 @@ L.TileLayer = L.Class.extend({ L.Util.setOptions(this, options); // detecting retina displays, adjusting tileSize - if (window.devicePixelRatio > 1) { + if (this.options.detectRetina && window.devicePixelRatio > 1) { this.options.tileSize >>= 1; } From cc0fc0e5b7620df3c4d08da7f0c99ee5ed9a1f49 Mon Sep 17 00:00:00 2001 From: Mithgol the Webmaster Date: Fri, 30 Mar 2012 09:46:31 +0400 Subject: [PATCH 09/23] adjust zoom levels as well (otherwise markers seem mispositioned) --- src/layer/tile/TileLayer.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/layer/tile/TileLayer.js b/src/layer/tile/TileLayer.js index 8992d34d..15df4208 100644 --- a/src/layer/tile/TileLayer.js +++ b/src/layer/tile/TileLayer.js @@ -28,9 +28,15 @@ L.TileLayer = L.Class.extend({ initialize: function (url, options) { L.Util.setOptions(this, options); - // detecting retina displays, adjusting tileSize - if (this.options.detectRetina && window.devicePixelRatio > 1) { + // detecting retina displays, adjusting tileSize and zoom levels + if (this.options.detectRetina + && window.devicePixelRatio > 1 + && options.maxZoom > 0 + ){ this.options.tileSize >>= 1; + options.zoomOffset++; + if (options.minZoom > 0) options.minZoom--; + options.maxZoom--; } this._url = url; From a73b812fe1e6b089225b33da049de99fdbb32dd8 Mon Sep 17 00:00:00 2001 From: Reed Date: Sun, 1 Apr 2012 15:39:00 -0400 Subject: [PATCH 10/23] fixed _checkIfEmpty in Circle.js with check for _map property --- src/layer/vector/Circle.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/layer/vector/Circle.js b/src/layer/vector/Circle.js index b6ac456f..8c7a3923 100644 --- a/src/layer/vector/Circle.js +++ b/src/layer/vector/Circle.js @@ -73,6 +73,7 @@ L.Circle = L.Path.extend({ }, _checkIfEmpty: function () { + if(!this._map) return false; var vp = this._map._pathViewport, r = this._radius, p = this._point; From ecec332504d714a75d7beed8ee2ba666426c1d03 Mon Sep 17 00:00:00 2001 From: djomp Date: Tue, 3 Apr 2012 10:42:29 +0200 Subject: [PATCH 11/23] Fix for passing jake jshint --- src/layer/vector/Circle.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/layer/vector/Circle.js b/src/layer/vector/Circle.js index 8c7a3923..b4848dfb 100644 --- a/src/layer/vector/Circle.js +++ b/src/layer/vector/Circle.js @@ -73,7 +73,9 @@ L.Circle = L.Path.extend({ }, _checkIfEmpty: function () { - if(!this._map) return false; + if (!this._map) { + return false; + } var vp = this._map._pathViewport, r = this._radius, p = this._point; From a8fa869a41cc286cd977fb490bb0d285f44993da Mon Sep 17 00:00:00 2001 From: Mithgol the Webmaster Date: Sun, 8 Apr 2012 05:10:32 +0400 Subject: [PATCH 12/23] includes fixes provided by Max Ogden --- src/layer/tile/TileLayer.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/layer/tile/TileLayer.js b/src/layer/tile/TileLayer.js index 15df4208..881a096f 100644 --- a/src/layer/tile/TileLayer.js +++ b/src/layer/tile/TileLayer.js @@ -29,14 +29,13 @@ L.TileLayer = L.Class.extend({ L.Util.setOptions(this, options); // detecting retina displays, adjusting tileSize and zoom levels - if (this.options.detectRetina - && window.devicePixelRatio > 1 - && options.maxZoom > 0 - ){ - this.options.tileSize >>= 1; - options.zoomOffset++; - if (options.minZoom > 0) options.minZoom--; - options.maxZoom--; + if (this.options.detectRetina && window.devicePixelRatio > 1 && this.options.maxZoom > 0) { + this.options.tileSize = Math.floor(this.options.tileSize / 2); + this.options.zoomOffset++; + if (this.options.minZoom > 0) { + this.options.minZoom--; + } + this.options.maxZoom--; } this._url = url; From d06de05e4be105bb3220a7ec6e79f56bcce58ac3 Mon Sep 17 00:00:00 2001 From: Michael Aufreiter Date: Thu, 12 Apr 2012 01:24:40 -0300 Subject: [PATCH 13/23] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b359c85d..01e73409 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ Leaflet -Leaflet is a modern, lightweight open-source JavaScript library for mobile-friendly interactive maps, developed by [CloudMade](http://cloudmade.com) to form the core of its next generation JavaScript API. Weighting just about 21kb of gzipped JS code, it still has all the [features](http://leaflet.cloudmade.com/features.html) you will ever need for you web mapping needs while providing a fast, smooth, pleasant user experience. +Leaflet is a modern, lightweight open-source JavaScript library for mobile-friendly interactive maps, developed by [CloudMade](http://cloudmade.com) to form the core of its next generation JavaScript API. Weighting just about 21kb of gzipped JS code, it still has all the [features](http://leaflet.cloudmade.com/features.html) you will ever need for your web mapping needs while providing a fast, smooth, 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, utilizing cutting-edge technologies included in HTML5 and CSS3, focusing 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). The OOP-based code of the library is designed to be modular, extensible and very easy to understand. From 1195ac3eeaa26c89a050598e8e3bd55ddc10e27c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Ravni=C4=87?= Date: Fri, 27 Apr 2012 14:52:06 +0200 Subject: [PATCH 14/23] code reformating to make it compliant with jake --- src/dom/DomUtil.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/dom/DomUtil.js b/src/dom/DomUtil.js index 4fb6c975..94fa8fd2 100644 --- a/src/dom/DomUtil.js +++ b/src/dom/DomUtil.js @@ -33,11 +33,11 @@ L.DomUtil = { L.DomUtil.getStyle(el, 'position') === 'absolute') { break; } - if ( L.DomUtil.getStyle(el, 'position') === 'fixed'){ - top += docBody.scrollTop || 0; - left += docBody.scrollLeft || 0; - break; - } + if (L.DomUtil.getStyle(el, 'position') === 'fixed') { + top += docBody.scrollTop || 0; + left += docBody.scrollLeft || 0; + break; + } el = el.offsetParent; } while (el); From 91e01dc64e3c1e663a12d14b2625cafd847c939f Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 27 Apr 2012 12:46:41 -0700 Subject: [PATCH 15/23] Add getContainer() method to L.Map as per the documentation. --- src/map/Map.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/map/Map.js b/src/map/Map.js index b74d91a6..40cf30f5 100644 --- a/src/map/Map.js +++ b/src/map/Map.js @@ -322,6 +322,10 @@ L.Map = L.Class.extend({ getPanes: function () { return this._panes; }, + + getContainer: function () { + return this._container; + }, // conversion methods From 1ffedae5ab7621f4d59dcd0be640ae62b029a042 Mon Sep 17 00:00:00 2001 From: Aaron King Date: Fri, 27 Apr 2012 12:49:57 -0700 Subject: [PATCH 16/23] Add getContainer() method to L.Map as per the documentation. --- src/map/Map.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/map/Map.js b/src/map/Map.js index b74d91a6..40cf30f5 100644 --- a/src/map/Map.js +++ b/src/map/Map.js @@ -322,6 +322,10 @@ L.Map = L.Class.extend({ getPanes: function () { return this._panes; }, + + getContainer: function () { + return this._container; + }, // conversion methods From 69aa3500ffcfeb3695819b1be1010772a5b6da2e Mon Sep 17 00:00:00 2001 From: Aaron King Date: Mon, 30 Apr 2012 15:52:23 -0700 Subject: [PATCH 17/23] Add getLatLng() and getRadius() methods to L.Circle. --- src/layer/vector/Circle.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/layer/vector/Circle.js b/src/layer/vector/Circle.js index b4848dfb..333c0e27 100644 --- a/src/layer/vector/Circle.js +++ b/src/layer/vector/Circle.js @@ -45,6 +45,10 @@ L.Circle = L.Path.extend({ return new L.LatLngBounds(sw, ne); }, + + getLatLng: function () { + return this._latlng; + }, getPathString: function () { var p = this._point, @@ -64,6 +68,10 @@ L.Circle = L.Path.extend({ return "AL " + p.x + "," + p.y + " " + r + "," + r + " 0," + (65535 * 360); } }, + + getRadius: function () { + return this._mRadius; + }, _getLngRadius: function () { var equatorLength = 40075017, From cfbf31721baef9ac01768f2f34c2590f3e63556e Mon Sep 17 00:00:00 2001 From: emartinez Date: Tue, 1 May 2012 18:04:27 -0600 Subject: [PATCH 18/23] Patch so setPosition works properly on Control. --- src/control/Control.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/control/Control.js b/src/control/Control.js index f634e773..1baee7c6 100644 --- a/src/control/Control.js +++ b/src/control/Control.js @@ -13,11 +13,16 @@ L.Control = L.Class.extend({ }, setPosition: function (position) { + var map = this._map; + + if (map) { + map.removeControl(this); + } + this.options.position = position; - if (this._map) { - this._map.removeControl(this); - this._map.addControl(this); + if (map) { + map.addControl(this); } }, From 434e09f01b4dfa1dc52f63f19ba6b70cf6a3962c Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Sat, 5 May 2012 13:13:07 +0200 Subject: [PATCH 19/23] ie6 filter clearing fix --- src/dom/DomUtil.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dom/DomUtil.js b/src/dom/DomUtil.js index 94fa8fd2..364210d7 100644 --- a/src/dom/DomUtil.js +++ b/src/dom/DomUtil.js @@ -104,7 +104,7 @@ L.DomUtil = { setOpacity: function (el, value) { if (L.Browser.ie) { - el.style.filter = value !== 1 ? 'alpha(opacity=' + Math.round(value * 100) + ')' : ''; + el.style.filter += value !== 1 ? 'alpha(opacity=' + Math.round(value * 100) + ')' : ''; } else { el.style.opacity = value; } From d6af5e8e03485258af31026aadf0d21cd9e91031 Mon Sep 17 00:00:00 2001 From: Charlie Savage Date: Mon, 7 May 2012 00:05:47 -0600 Subject: [PATCH 20/23] this.edit is not always set for polygons - this happens to us for example when loading from geojson. This patch makes sure that this.editing is set before checking whether editing is enabled. --- src/layer/vector/Polyline.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/layer/vector/Polyline.js b/src/layer/vector/Polyline.js index c66edb8c..5d1a1daf 100644 --- a/src/layer/vector/Polyline.js +++ b/src/layer/vector/Polyline.js @@ -90,7 +90,7 @@ L.Polyline = L.Path.extend({ onAdd: function (map) { L.Path.prototype.onAdd.call(this, map); - if (this.editing.enabled()) { + if (this.editing && this.editing.enabled()) { this.editing.addHooks(); } }, From b0486f2e0bda6b48e1b91a4fd002050789236825 Mon Sep 17 00:00:00 2001 From: Peter Gassner Date: Mon, 7 May 2012 16:56:30 +0300 Subject: [PATCH 21/23] Fix feature detection for IE9 when drawing SVG paths --- src/layer/vector/Path.SVG.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/layer/vector/Path.SVG.js b/src/layer/vector/Path.SVG.js index 65e178b2..c544cc5b 100644 --- a/src/layer/vector/Path.SVG.js +++ b/src/layer/vector/Path.SVG.js @@ -69,7 +69,7 @@ L.Path = L.Path.extend({ // TODO remove duplication with L.Map _initEvents: function () { if (this.options.clickable) { - if (!L.Browser.vml) { + if (L.Browser.svg || !L.Browser.vml) { this._path.setAttribute('class', 'leaflet-clickable'); } From 081b75b6e82ed53b0a12bc8a8a04d9dc1cb3d19b Mon Sep 17 00:00:00 2001 From: Graeme West Date: Thu, 10 May 2012 10:05:54 +0100 Subject: [PATCH 22/23] Fixing indentation so that Leaflet compiles. --- src/layer/tile/TileLayer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/layer/tile/TileLayer.js b/src/layer/tile/TileLayer.js index 881a096f..7a27dd48 100644 --- a/src/layer/tile/TileLayer.js +++ b/src/layer/tile/TileLayer.js @@ -33,7 +33,7 @@ L.TileLayer = L.Class.extend({ this.options.tileSize = Math.floor(this.options.tileSize / 2); this.options.zoomOffset++; if (this.options.minZoom > 0) { - this.options.minZoom--; + this.options.minZoom--; } this.options.maxZoom--; } From 8b2bda9bc3e54ae0f10bc4f5aac0a3a00a264145 Mon Sep 17 00:00:00 2001 From: Graeme West Date: Thu, 10 May 2012 11:45:06 +0100 Subject: [PATCH 23/23] Converting spaces to tabs for consistency. --- src/layer/tile/TileLayer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/layer/tile/TileLayer.js b/src/layer/tile/TileLayer.js index 7a27dd48..d92bab6f 100644 --- a/src/layer/tile/TileLayer.js +++ b/src/layer/tile/TileLayer.js @@ -33,7 +33,7 @@ L.TileLayer = L.Class.extend({ this.options.tileSize = Math.floor(this.options.tileSize / 2); this.options.zoomOffset++; if (this.options.minZoom > 0) { - this.options.minZoom--; + this.options.minZoom--; } this.options.maxZoom--; }