Merge remote-tracking branch 'origin/master'

This commit is contained in:
mourner 2012-05-10 17:08:14 +03:00
commit c188756573
10 changed files with 80 additions and 8 deletions

View File

@ -1,6 +1,6 @@
<img src="http://leaflet.cloudmade.com/docs/images/logo.png" alt="Leaflet" /> <img src="http://leaflet.cloudmade.com/docs/images/logo.png" alt="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. 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.

View File

@ -0,0 +1,35 @@
<!DOCTYPE html>
<html>
<head>
<title>Leaflet geolocation debug page</title>
<link rel="stylesheet" href="../../dist/leaflet.css" />
<!--[if lte IE 8]><link rel="stylesheet" href="../../dist/leaflet.ie.css" /><![endif]-->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="../css/screen.css" />
<script src="../leaflet-include.js"></script>
</head>
<body>
<div id="map"></div>
<script type="text/javascript">
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png',
cloudmadeAttribution = 'Map data &copy; 2011 OpenStreetMap contributors, Imagery &copy; 2011 CloudMade',
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18, attribution: cloudmadeAttribution});
var map = new L.Map('map', {zoom: 15, layers: [cloudmade]});
function logEvent(e) { console.log(e.type); }
map.on('locationerror', logEvent);
map.on('locationfound', logEvent);
map.locate({setView: true});
</script>
</body>
</html>

View File

@ -13,11 +13,16 @@ L.Control = L.Class.extend({
}, },
setPosition: function (position) { setPosition: function (position) {
var map = this._map;
if (map) {
map.removeControl(this);
}
this.options.position = position; this.options.position = position;
if (this._map) { if (map) {
this._map.removeControl(this); map.addControl(this);
this._map.addControl(this);
} }
}, },

View File

@ -17,7 +17,7 @@ L.Util = {
}, },
bind: function (fn, obj) { // (Function, Object) -> Function 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 function () {
return fn.apply(obj, args || arguments); return fn.apply(obj, args || arguments);
}; };

View File

@ -33,6 +33,12 @@ L.DomUtil = {
L.DomUtil.getStyle(el, 'position') === 'absolute') { L.DomUtil.getStyle(el, 'position') === 'absolute') {
break; break;
} }
if (L.DomUtil.getStyle(el, 'position') === 'fixed') {
top += docBody.scrollTop || 0;
left += docBody.scrollLeft || 0;
break;
}
el = el.offsetParent; el = el.offsetParent;
} while (el); } while (el);
@ -98,7 +104,7 @@ L.DomUtil = {
setOpacity: function (el, value) { setOpacity: function (el, value) {
if (L.Browser.ie) { 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 { } else {
el.style.opacity = value; el.style.opacity = value;
} }

View File

@ -18,6 +18,7 @@ L.TileLayer = L.Class.extend({
noWrap: false, noWrap: false,
zoomOffset: 0, zoomOffset: 0,
zoomReverse: false, zoomReverse: false,
detectRetina: false,
unloadInvisibleTiles: L.Browser.mobile, unloadInvisibleTiles: L.Browser.mobile,
updateWhenIdle: L.Browser.mobile, updateWhenIdle: L.Browser.mobile,
@ -27,6 +28,16 @@ L.TileLayer = L.Class.extend({
initialize: function (url, options) { initialize: function (url, options) {
L.Util.setOptions(this, 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; this._url = url;
var subdomains = this.options.subdomains; var subdomains = this.options.subdomains;

View File

@ -45,6 +45,10 @@ L.Circle = L.Path.extend({
return new L.LatLngBounds(sw, ne); return new L.LatLngBounds(sw, ne);
}, },
getLatLng: function () {
return this._latlng;
},
getPathString: function () { getPathString: function () {
var p = this._point, var p = this._point,
@ -64,6 +68,10 @@ L.Circle = L.Path.extend({
return "AL " + p.x + "," + p.y + " " + r + "," + r + " 0," + (65535 * 360); return "AL " + p.x + "," + p.y + " " + r + "," + r + " 0," + (65535 * 360);
} }
}, },
getRadius: function () {
return this._mRadius;
},
_getLngRadius: function () { _getLngRadius: function () {
var equatorLength = 40075017, var equatorLength = 40075017,
@ -73,6 +81,9 @@ L.Circle = L.Path.extend({
}, },
_checkIfEmpty: function () { _checkIfEmpty: function () {
if (!this._map) {
return false;
}
var vp = this._map._pathViewport, var vp = this._map._pathViewport,
r = this._radius, r = this._radius,
p = this._point; p = this._point;

View File

@ -69,7 +69,7 @@ L.Path = L.Path.extend({
// TODO remove duplication with L.Map // TODO remove duplication with L.Map
_initEvents: function () { _initEvents: function () {
if (this.options.clickable) { if (this.options.clickable) {
if (!L.Browser.vml) { if (L.Browser.svg || !L.Browser.vml) {
this._path.setAttribute('class', 'leaflet-clickable'); this._path.setAttribute('class', 'leaflet-clickable');
} }

View File

@ -90,7 +90,7 @@ L.Polyline = L.Path.extend({
onAdd: function (map) { onAdd: function (map) {
L.Path.prototype.onAdd.call(this, map); L.Path.prototype.onAdd.call(this, map);
if (this.editing.enabled()) { if (this.editing && this.editing.enabled()) {
this.editing.addHooks(); this.editing.addHooks();
} }
}, },

View File

@ -322,6 +322,10 @@ L.Map = L.Class.extend({
getPanes: function () { getPanes: function () {
return this._panes; return this._panes;
}, },
getContainer: function () {
return this._container;
},
// conversion methods // conversion methods