Skip to content

Commit

Permalink
Merge remote branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner committed May 12, 2011
2 parents aeffc6d + 66f00bf commit 3352242
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 50 deletions.
7 changes: 3 additions & 4 deletions debug/map/map-mobile.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@

var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png',
cloudmadeAttribution = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18, attribution: cloudmadeAttribution}),
latlng = new L.LatLng(50.5, 30.51);
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18, attribution: cloudmadeAttribution});

var map = new L.Map('map').addLayer(cloudmade).setView(latlng, 15);
var map = new L.Map('map').addLayer(cloudmade).setView(new L.LatLng(50.5, 30.51), 15);

map.on('locationfound', function(e) {
var marker = new L.Marker(e.latlng);
Expand All @@ -32,7 +31,7 @@
marker.bindPopup("<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</p><p>Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim pellentesque felis.</p>");
});

map.locate();
map.locateAndSetView();
</script>
</body>
</html>
30 changes: 15 additions & 15 deletions dist/leaflet.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/handler/MarkerDrag.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ L.Handler.MarkerDrag = L.Handler.extend({
},

moved: function() {
return this._draggable._moved;
return this._draggable && this._draggable._moved;
},

_onDragStart: function(e) {
Expand Down
10 changes: 6 additions & 4 deletions src/layer/Popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ L.Popup = L.Class.extend({
autoPan: true,
closeButton: true,

offset: new L.Point(0, 0),
offset: new L.Point(0, 2),
autoPanPadding: new L.Point(5, 5)
},

Expand All @@ -19,15 +19,15 @@ L.Popup = L.Class.extend({
this._map = map;
if (!this._container) {
this._initLayout();
this._updateContent();
}
this._updateContent();

this._container.style.opacity = '0';

this._map._panes.popupPane.appendChild(this._container);
this._map.on('viewreset', this._updatePosition, this);
if (this._map.options.closePopupOnClick) {
this._map.on('click', this._close, this);
this._map.on('preclick', this._close, this);
}
this._update();

Expand All @@ -51,13 +51,15 @@ L.Popup = L.Class.extend({
if (this._opened) {
this._update();
}
return this;
},

setContent: function(content) {
this._content = content;
if (this._opened) {
this._update();
}
return this;
},

_close: function() {
Expand Down Expand Up @@ -115,7 +117,7 @@ L.Popup = L.Class.extend({
var pos = this._map.latLngToLayerPoint(this._latlng);

this._containerBottom = -pos.y - this.options.offset.y;
this._containerLeft = pos.x - this._containerWidth/2 + this.options.offset.x;
this._containerLeft = pos.x - Math.round(this._containerWidth/2) + this.options.offset.x;

this._container.style.bottom = this._containerBottom + 'px';
this._container.style.left = this._containerLeft + 'px';
Expand Down
11 changes: 8 additions & 3 deletions src/layer/vector/Path.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ L.Path = L.Class.extend({
fillColor: null, //same as color by default
fillOpacity: 0.2,

clickable: true,

updateOnMoveEnd: false
},

Expand Down Expand Up @@ -158,9 +160,12 @@ L.Path = L.Class.extend({

// TODO remove duplication with L.Map
_initEvents: function() {
L.DomEvent.addListener(this._container, 'click', this._onMouseClick, this);
L.DomEvent.addListener(this._container, 'dblclick', this._fireMouseEvent, this);
L.DomEvent.addListener(this._container, 'mousedown', this._fireMouseEvent, this);
if (this.options.clickable) {
this._path.setAttribute('class', 'leaflet-clickable');
L.DomEvent.addListener(this._container, 'click', this._onMouseClick, this);
L.DomEvent.addListener(this._container, 'dblclick', this._fireMouseEvent, this);
L.DomEvent.addListener(this._container, 'mousedown', this._fireMouseEvent, this);
}
},

_onMouseClick: function(e) {
Expand Down
2 changes: 2 additions & 0 deletions src/map/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,12 @@ L.Map = L.Class.extend({

_onMouseClick: function(e) {
if (this.dragging && this.dragging.moved()) { return; }

this._fireMouseEvent(e);
},

_fireMouseEvent: function(e) {
this.fire('pre' + e.type);
if (!this.hasEventListeners(e.type)) { return; }
this.fire(e.type, {
latlng: this.mouseEventToLatLng(e),
Expand Down
40 changes: 21 additions & 19 deletions src/map/ext/Map.Control.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,4 @@
L.Map.include({
_initControlPos: function() {
var corners = this._controlCorners = {},
classPart = 'leaflet-',
top = classPart + 'top',
bottom = classPart + 'bottom',
left = classPart + 'left',
right = classPart + 'right',
controlContainer = L.DomUtil.create('div', classPart + 'control-container', this._container);

if (L.Browser.mobileWebkit) {
controlContainer.className += ' ' + classPart + 'big-buttons';
}

corners.topLeft = L.DomUtil.create('div', top + ' ' + left, controlContainer);
corners.topRight = L.DomUtil.create('div', top + ' ' + right, controlContainer);
corners.bottomLeft = L.DomUtil.create('div', bottom + ' ' + left, controlContainer);
corners.bottomRight = L.DomUtil.create('div', bottom + ' ' + right, controlContainer);
},

addControl: function(control) {
control.onAdd(this);

Expand All @@ -32,6 +13,7 @@ L.Map.include({
} else {
corner.appendChild(container);
}
return this;
},

removeControl: function(conrol) {
Expand All @@ -44,5 +26,25 @@ L.Map.include({
if (control.onRemove) {
control.onRemove(this);
}
return this;
},

_initControlPos: function() {
var corners = this._controlCorners = {},
classPart = 'leaflet-',
top = classPart + 'top',
bottom = classPart + 'bottom',
left = classPart + 'left',
right = classPart + 'right',
controlContainer = L.DomUtil.create('div', classPart + 'control-container', this._container);

if (L.Browser.mobileWebkit) {
controlContainer.className += ' ' + classPart + 'big-buttons';
}

corners.topLeft = L.DomUtil.create('div', top + ' ' + left, controlContainer);
corners.topRight = L.DomUtil.create('div', top + ' ' + right, controlContainer);
corners.bottomLeft = L.DomUtil.create('div', bottom + ' ' + left, controlContainer);
corners.bottomRight = L.DomUtil.create('div', bottom + ' ' + right, controlContainer);
}
});
13 changes: 10 additions & 3 deletions src/map/ext/Map.Geolocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,22 @@
*/

L.Map.include({
locate: function(/*Boolean*/ noFitBounds) {
locate: function() {
if (navigator.geolocation) {
this._fitBoundsOnLocate = !noFitBounds;
navigator.geolocation.getCurrentPosition(
L.Util.bind(this._handleGeolocationResponse, this),
L.Util.bind(this._handleGeolocationError, this));
} else {
this.fire('locationerror', {message: "Geolocation not supported."});
}
return this;
},

locateAndSetView: function(maxZoom) {
this._setViewOnLocate = true;
return this.locate();
},

_handleGeolocationError: function(error) {
this.fire('locationerror', {message: error.message});
},
Expand All @@ -27,8 +33,9 @@ L.Map.include({
ne = new L.LatLng(lat + latAccuracy, lng + lngAccuracy),
bounds = new L.LatLngBounds(sw, ne);

if (this._fitBoundsOnLocate) {
if (this._setViewOnLocate) {
this.fitBounds(bounds);
this._setViewOnLocate = false;
}

this.fire('locationfound', {
Expand Down
3 changes: 2 additions & 1 deletion src/map/ext/Map.Popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ L.Map.include({
openPopup: function(popup) {
this.closePopup();
this._popup = popup;
this.addLayer(popup);
return this.addLayer(popup);
},

closePopup: function() {
if (this._popup) {
this.removeLayer(this._popup);
}
return this;
}
});

0 comments on commit 3352242

Please sign in to comment.