leaflet: misc minor improvements
* map may not have hasLayer defined during initialization, so we protect against it. * Show the inner html elements of the comment boxes before showing the comment itself (smoother UI experience). * Reorder getBounds call first to short-circuit early. Change-Id: I0235d43d19c1b712df266d6e39738b1415c5d048
This commit is contained in:
parent
3a6f66817b
commit
cb520986e7
2 changed files with 8 additions and 5 deletions
|
@ -294,12 +294,14 @@ L.AnnotationManager = L.Class.extend({
|
|||
if (!this._map || this._map.animatingZoom || this._items.length === 0) {
|
||||
return;
|
||||
}
|
||||
var maxBounds = this._map.getLayerMaxBounds();
|
||||
|
||||
var thisBounds = this.getBounds();
|
||||
if (!thisBounds)
|
||||
return;
|
||||
var margin = this._items[0].getMargin();
|
||||
|
||||
var maxBounds = this._map.getLayerMaxBounds();
|
||||
if (!maxBounds.contains(thisBounds)) {
|
||||
var margin = this._items[0].getMargin();
|
||||
var docBounds = this._map.getLayerDocBounds();
|
||||
var delta = L.point(Math.max(thisBounds.max.x - docBounds.max.x, 0), Math.max(thisBounds.max.y - docBounds.max.y, 0));
|
||||
if (delta.x > 0) {
|
||||
|
|
|
@ -71,6 +71,7 @@ L.Annotation = L.Layer.extend({
|
|||
return this;
|
||||
},
|
||||
|
||||
/// Returns two points: the top-left (min) and the bottom-right (max).
|
||||
getBounds: function () {
|
||||
var point = this._map.latLngToLayerPoint(this._latlng);
|
||||
return L.bounds(point, point.add(L.point(this._container.offsetWidth, this._container.offsetHeight)));
|
||||
|
@ -85,7 +86,7 @@ L.Annotation = L.Layer.extend({
|
|||
this._contentNode.style.display = '';
|
||||
this._nodeModify.style.display = 'none';
|
||||
this._nodeReply.style.display = 'none';
|
||||
if (this._data.textSelected && !this._map.hasLayer(this._data.textSelected)) {
|
||||
if (this._data.textSelected && this._map.hasLayer && !this._map.hasLayer(this._data.textSelected)) {
|
||||
this._map.addLayer(this._data.textSelected);
|
||||
}
|
||||
},
|
||||
|
@ -105,10 +106,10 @@ L.Annotation = L.Layer.extend({
|
|||
},
|
||||
|
||||
edit: function () {
|
||||
this._container.style.visibility = '';
|
||||
this._contentNode.style.display = 'none';
|
||||
this._nodeModify.style.display = '';
|
||||
this._nodeReply.style.display = 'none';
|
||||
this._container.style.visibility = '';
|
||||
this._contentNode.style.display = 'none';
|
||||
return this;
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue