Skip to content

Commit

Permalink
merge changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner committed Jul 20, 2012
2 parents f1c4a1f + 0d7ab0a commit daf7a81
Show file tree
Hide file tree
Showing 22 changed files with 314 additions and 99 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ node_modules
tmp/**/*
.idea
.idea/**/*
*.iml
*.iml
*.sublime-*
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Icon API was improved to be more flexible, but one of the changes is backwards-i
* Added `L_NO_TOUCH` global variable switch (set it before Leaflet inclusion) which disables touch detection, helpful for desktop apps built using QT. [#572](https://github.com/CloudMade/Leaflet/issues/572)
* Added `Circle` `getBounds` method. [#440](https://github.com/CloudMade/Leaflet/issues/440)
* Added `Circle` `getLatLng` and `getRadius` methods (by [@Guiswa](https://github.com/Guiswa)). [#655](https://github.com/CloudMade/Leaflet/pull/655)
* Added `openPopup` method to all vector layers. [#246](https://github.com/CloudMade/Leaflet/issues/246)
* Added public `redraw` method to vector layers (useful if you manipulate their `LatLng` points directly).
* Added `Marker` `opacity` option and `setOpacity` method.
* Added `Marker` `update` method. [#392](https://github.com/CloudMade/Leaflet/issues/392)
Expand Down Expand Up @@ -140,11 +141,14 @@ Icon API was improved to be more flexible, but one of the changes is backwards-i
#### Mobile browser bugfixes

* Fixed a bug that sometimes caused map to disappear completely after zoom on iOS (by [@fr1n63](https://github.com/fr1n63)). [#580](https://github.com/CloudMade/Leaflet/issues/580) [#777](https://github.com/CloudMade/Leaflet/pull/777)
* Fixed a bug that often caused vector layers to flicker on drag end on iOS (by [@krawaller](https://github.com/krawaller)). [#18](https://github.com/CloudMade/Leaflet/issues/18)
* Fixed a bug with false map click events on pinch-zoom and zoom/layers controls click. [#485](https://github.com/CloudMade/Leaflet/issues/485)
* Fixed a bug where touching the map with two or more fingers simultaneously would raise an error.
* Fixed a bug where zoom control wasn't always visible on Android 3. [#335](https://github.com/CloudMade/Leaflet/issues/335)
* Fixed a bug where opening the layers control would propagate a click to the map (by [@jacobtoye](https://github.com/jacobtoye)). [#638](https://github.com/CloudMade/Leaflet/pull/638)
* Fixed a bug where `ImageOverlay` wouldn't stretch properly on zoom on Android 2. [#651](https://github.com/CloudMade/Leaflet/issues/651)
* Fixed a bug where `clearLayers` for vector layers on a Canvas backend (e.g. on Android 2) would take unreasonable amount of time. [#785](https://github.com/CloudMade/Leaflet/issues/785)
* Fixed a bug where `setLatLngs` and similar methods on vector layers on a Canvas backend would not update the layers immediately. [#732](https://github.com/CloudMade/Leaflet/issues/732)

## 0.3.1 (February 14, 2012)

Expand Down
2 changes: 1 addition & 1 deletion build/deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var deps = {
},

Marker: {
src: ['layer/marker/Icon.js', 'layer/marker/Marker.js'],
src: ['layer/marker/Icon.js', 'layer/marker/Icon.Default.js', 'layer/marker/Marker.js'],
desc: 'Markers to put on the map.'
},

Expand Down
42 changes: 42 additions & 0 deletions debug/hacks/jitter.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!DOCTYPE html>
<html>
<head>
<title>Leaflet 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 maximum-scale=1.0 user-scalable=0">
<link rel="stylesheet" href="../css/screen.css" />

<script src="../leaflet-include.js"></script>
</head>
<body>

<div id="map"></div>
<div >
<form method="get">Click in field then scroll map (in up/left direction) to see shift of map tiles.
<fieldset><label for="textField">Name</label>:
<input id="textField" name="textField" type="text" value="">
</fieldset>
</form>
Bug tested to occur on: Safari on Mac (Tested in 5.1.7), iPad/iPhone 5.1.1., Android 4 Browser. Hack is in L.Browser.chrome and TileLayer._addTile

</div>
<script type="text/javascript">

var cloudmade = L.tileLayer('http://{s}.tile.cloudmade.com/{key}/997/256/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: 'Map data &copy; 2011 OpenStreetMap contributors, Imagery &copy; 2011 CloudMade',
key: 'BC9A493B41014CAABB98F0471D759707'
});

//Disable the hack fix
L.Browser.chrome = true;

var map = L.map('map')
.setView([50.5, 30.51], 15)
.addLayer(cloudmade);
</script>
</body>
</html>
1 change: 1 addition & 0 deletions debug/leaflet-include.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
'layer/Popup.js',

'layer/marker/Icon.js',
'layer/marker/Icon.Default.js',
'layer/marker/DivIcon.js',
'layer/marker/Marker.js',
'layer/marker/Marker.Popup.js',
Expand Down
132 changes: 108 additions & 24 deletions dist/leaflet-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ L.Mixin.Events.fire = L.Mixin.Events.fireEvent;
ie6 = ie && !window.XMLHttpRequest,
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,
Expand Down Expand Up @@ -383,6 +385,8 @@ L.Mixin.Events.fire = L.Mixin.Events.fireEvent;
android: android,
android23: android23,

chrome: chrome,

ie3d: ie3d,
webkit3d: webkit3d,
gecko3d: gecko3d,
Expand Down Expand Up @@ -1635,8 +1639,8 @@ L.Map = L.Class.extend({

L.DomEvent.on(this._container, 'click', this._onMouseClick, this);

var events = ['dblclick', 'mousedown', 'mousedown', 'mouseenter', 'mouseleave', 'mousemove', 'contextmenu'],
i, len;
var events = ['dblclick', 'mousedown', 'mouseup', 'mouseenter', 'mouseleave', 'mousemove', 'contextmenu'],
i, len;

for (i = 0, len = events.length; i < len; i++) {
L.DomEvent.on(this._container, events[i], this._fireMouseEvent, this);
Expand Down Expand Up @@ -2137,7 +2141,11 @@ L.TileLayer = L.Class.extend({

// get unused tile - or create a new tile
var tile = this._getTile();
L.DomUtil.setPosition(tile, tilePos, true);

// Chrome 20 layouts much faster with top/left (Verify with timeline, frames), Safari 5.1.7, iOS 5.1.1,
// android browser (4.0) have display issues with top/left and requires transform instead
// (other browsers don't currently care) - see debug/hacks/jitter.html for an example
L.DomUtil.setPosition(tile, tilePos, L.Browser.chrome);

this._tiles[key] = tile;

Expand Down Expand Up @@ -2279,7 +2287,12 @@ L.TileLayer.WMS = L.TileLayer.extend({
this._url = url;

var wmsParams = L.Util.extend({}, this.defaultWmsParams);
wmsParams.width = wmsParams.height = this.options.tileSize;

if (options.detectRetina && window.devicePixelRatio > 1) {
wmsParams.width = wmsParams.height = this.options.tileSize * 2;
} else {
wmsParams.width = wmsParams.height = this.options.tileSize;
}

for (var i in options) {
// all keys that are not TileLayer options go to WMS params
Expand Down Expand Up @@ -2546,7 +2559,7 @@ L.Icon = L.Class.extend({
}
return null;
}

var img = this._createImg(src);
this._setIconStyles(img, name);

Expand Down Expand Up @@ -2603,13 +2616,13 @@ L.icon = function (options) {
};


// TODO move to a separate file

L.Icon.Default = L.Icon.extend({

options: {
iconSize: new L.Point(25, 41),
iconAnchor: new L.Point(13, 41),
popupAnchor: new L.Point(0, -33),
popupAnchor: new L.Point(1, -34),

shadowSize: new L.Point(41, 41)
},
Expand All @@ -2622,7 +2635,7 @@ L.Icon.Default = L.Icon.extend({
}

var path = L.Icon.Default.imagePath;

if (!path) {
throw new Error("Couldn't autodetect L.Icon.Default.imagePath, set it manually.");
}
Expand All @@ -2647,6 +2660,7 @@ L.Icon.Default.imagePath = (function () {
}
}());


/*
* L.Marker is used to display clickable/draggable icons on the map.
*/
Expand Down Expand Up @@ -2746,7 +2760,8 @@ L.Marker = L.Class.extend({
var options = this.options,
map = this._map,
animation = (map.options.zoomAnimation && map.options.markerZoomAnimation),
classToAdd = animation ? 'leaflet-zoom-animated' : 'leaflet-zoom-hide';
classToAdd = animation ? 'leaflet-zoom-animated' : 'leaflet-zoom-hide',
needOpacityUpdate = false;

if (!this._icon) {
this._icon = options.icon.createIcon();
Expand All @@ -2756,7 +2771,7 @@ L.Marker = L.Class.extend({
}

this._initInteraction();
this._updateOpacity();
needOpacityUpdate = true;

L.DomUtil.addClass(this._icon, classToAdd);
}
Expand All @@ -2765,9 +2780,14 @@ L.Marker = L.Class.extend({

if (this._shadow) {
L.DomUtil.addClass(this._shadow, classToAdd);
needOpacityUpdate = true;
}
}

if (needOpacityUpdate) {
this._updateOpacity();
}

var panes = this._map._panes;

panes.markerPane.appendChild(this._icon);
Expand Down Expand Up @@ -2854,8 +2874,11 @@ L.Marker = L.Class.extend({
}
},

_updateOpacity: function (opacity) {
_updateOpacity: function () {
L.DomUtil.setOpacity(this._icon, this.options.opacity);
if (this._shadow) {
L.DomUtil.setOpacity(this._shadow, this.options.opacity);
}
}
});

Expand Down Expand Up @@ -2917,7 +2940,7 @@ L.Popup = L.Class.extend({
maxHeight: null,
autoPan: true,
closeButton: true,
offset: new L.Point(0, 2),
offset: new L.Point(0, 6),
autoPanPadding: new L.Point(5, 5),
className: ''
},
Expand All @@ -2936,7 +2959,11 @@ L.Popup = L.Class.extend({
}
this._updateContent();

L.DomUtil.setOpacity(this._container, 0);
var animFade = map.options.fadeAnimation;

if (animFade) {
L.DomUtil.setOpacity(this._container, 0);
}
map._panes.popupPane.appendChild(this._container);

map.on('viewreset', this._updatePosition, this);
Expand All @@ -2951,7 +2978,9 @@ L.Popup = L.Class.extend({

this._update();

L.DomUtil.setOpacity(this._container, 1);
if (animFade) {
L.DomUtil.setOpacity(this._container, 1);
}
},

addTo: function (map) {
Expand All @@ -2975,7 +3004,9 @@ L.Popup = L.Class.extend({
zoomanim: this._zoomAnimation
}, this);

L.DomUtil.setOpacity(this._container, 0);
if (map.options.fadeAnimation) {
L.DomUtil.setOpacity(this._container, 0);
}

this._map = null;
},
Expand Down Expand Up @@ -3180,6 +3211,8 @@ L.Marker.include({
bindPopup: function (content, options) {
var anchor = L.point(this.options.icon.options.popupAnchor) || new L.Point(0, 0);

anchor = anchor.add(L.Popup.prototype.options.offset);

if (options && options.offset) {
anchor = anchor.add(options.offset);
}
Expand Down Expand Up @@ -3387,7 +3420,11 @@ L.Path = L.Class.extend({
statics: {
// how much to extend the clip area around the map view
// (relative to its size, e.g. 0.5 is half the screen in each direction)
CLIP_PADDING: 0.5
// set in such way that SVG element doesn't exceed 1280px (vector layers flicker on dragend if it is)
CLIP_PADDING: L.Browser.mobile ?
Math.max(0, Math.min(0.5,
(1280 / Math.max(window.innerWidth, window.innerHeight) - 1) / 2))
: 0.5
},

options: {
Expand Down Expand Up @@ -3680,10 +3717,13 @@ L.Map.include({
*/

L.Path.include({

bindPopup: function (content, options) {

if (!this._popup || this._popup.options !== options) {
this._popup = new L.Popup(options, this);
}

this._popup.setContent(content);

if (!this._openPopupAdded) {
Expand All @@ -3694,6 +3734,18 @@ L.Path.include({
return this;
},

openPopup: function (latlng) {

if (this._popup) {
latlng = latlng || this._latlng ||
this._latlngs[Math.floor(this._latlngs.length / 2)];

this._openPopup({latlng: latlng});
}

return this;
},

_openPopup: function (e) {
this._popup.setLatLng(e.latlng);
this._map.openPopup(this._popup);
Expand Down Expand Up @@ -3831,6 +3883,45 @@ L.Path = (L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? L.Path :
SVG: false
},

redraw: function () {
if (this._map) {
this.projectLatlngs();
this._requestUpdate();
}
return this;
},

setStyle: function (style) {
L.Util.setOptions(this, style);

if (this._map) {
this._updateStyle();
this._requestUpdate();
}
return this;
},

onRemove: function (map) {
map
.off('viewreset', this.projectLatlngs, this)
.off('moveend', this._updatePath, this);

this._requestUpdate();

this._map = null;
},

_requestUpdate: function () {
if (this._map) {
L.Util.cancelAnimFrame(this._fireMapMoveEnd);
this._updateRequest = L.Util.requestAnimFrame(this._fireMapMoveEnd, this._map);
}
},

_fireMapMoveEnd: function () {
this.fire('moveend');
},

_initElements: function () {
this._map._initPathRoot();
this._ctx = this._map._canvasCtx;
Expand Down Expand Up @@ -3912,14 +4003,7 @@ L.Path = (L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? L.Path :
if (this._containsPoint(e.layerPoint)) {
this.fire('click', e);
}
},

onRemove: function (map) {
map
.off('viewreset', this._projectLatlngs, this)
.off('moveend', this._updatePath, this)
.fire('moveend');
}
}
});

L.Map.include((L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? {} : {
Expand Down
Loading

0 comments on commit daf7a81

Please sign in to comment.