diff --git a/README.md b/README.md index b359c85d7e0..01e73409462 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. diff --git a/debug/map/geolocation.html b/debug/map/geolocation.html new file mode 100644 index 00000000000..7f5b0846df7 --- /dev/null +++ b/debug/map/geolocation.html @@ -0,0 +1,35 @@ + + + + Leaflet geolocation debug page + + + + + + + + + + + + +
+ + + + diff --git a/src/control/Control.js b/src/control/Control.js index f634e773632..1baee7c6d13 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); } }, diff --git a/src/core/Util.js b/src/core/Util.js index cba89f9cceb..bae1436e006 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); }; diff --git a/src/dom/DomUtil.js b/src/dom/DomUtil.js index 56a4ec1ba6c..364210d7531 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); @@ -98,7 +104,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; } diff --git a/src/layer/tile/TileLayer.js b/src/layer/tile/TileLayer.js index 76e66b32a20..d92bab6fd7b 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, @@ -27,6 +28,16 @@ L.TileLayer = L.Class.extend({ initialize: function (url, options) { L.Util.setOptions(this, options); + // detecting retina displays, adjusting tileSize and zoom levels + 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; var subdomains = this.options.subdomains; diff --git a/src/layer/vector/Circle.js b/src/layer/vector/Circle.js index 94d6aeddbe1..99989e13a55 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, @@ -73,6 +81,9 @@ L.Circle = L.Path.extend({ }, _checkIfEmpty: function () { + if (!this._map) { + return false; + } var vp = this._map._pathViewport, r = this._radius, p = this._point; diff --git a/src/layer/vector/Path.SVG.js b/src/layer/vector/Path.SVG.js index 65e178b24fb..c544cc5b704 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'); } diff --git a/src/layer/vector/Polyline.js b/src/layer/vector/Polyline.js index c66edb8ccfb..5d1a1dafca4 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(); } }, diff --git a/src/map/Map.js b/src/map/Map.js index b74d91a6a4e..40cf30f5842 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