map fixes (when loaded without places, zoom out; when resizing causes the minimum zoom to be larger than the current zoom, zoom out)
This commit is contained in:
parent
4c641db867
commit
45ad8ee468
1 changed files with 21 additions and 4 deletions
|
@ -553,6 +553,11 @@ Ox.Map = function(options, self) {
|
|||
}
|
||||
}
|
||||
|
||||
function crossesDateline() {
|
||||
var bounds = self.map.getBounds();
|
||||
return bounds.getSouthWest().lng() > bounds.getNorthEast().lng();
|
||||
}
|
||||
|
||||
function editing() {
|
||||
var place = getSelectedPlace();
|
||||
return place && place.editing;
|
||||
|
@ -769,7 +774,13 @@ Ox.Map = function(options, self) {
|
|||
} else if (self.options.selected) {
|
||||
selectPlace(self.options.selected, true);
|
||||
} else {
|
||||
mapBounds && self.map.fitBounds(mapBounds);
|
||||
if (mapBounds) {
|
||||
if (isEmpty(mapBounds)) {
|
||||
self.map.setZoom(self.minZoom);
|
||||
} else {
|
||||
self.map.fitBounds(mapBounds);
|
||||
}
|
||||
}
|
||||
if (self.map.getZoom() < self.minZoom) {
|
||||
self.map.setZoom(self.minZoom);
|
||||
}
|
||||
|
@ -801,9 +812,12 @@ Ox.Map = function(options, self) {
|
|||
}
|
||||
}
|
||||
|
||||
function crossesDateline() {
|
||||
var bounds = self.map.getBounds();
|
||||
return bounds.getSouthWest().lng() > bounds.getNorthEast().lng();
|
||||
function isEmpty(bounds) {
|
||||
// Google's bounds.isEmpty() is not reliable
|
||||
var southWest = bounds.getSouthWest(),
|
||||
northEast = bounds.getNorthEast();
|
||||
return southWest.lat() == northEast.lat()
|
||||
&& southWest.lng() == northEast.lng();
|
||||
}
|
||||
|
||||
function mapChanged() {
|
||||
|
@ -1396,6 +1410,9 @@ Ox.Map = function(options, self) {
|
|||
self.options.width = that.$element.width();
|
||||
self.mapHeight = getMapHeight();
|
||||
self.minZoom = getMinZoom();
|
||||
if (self.minZoom > self.map.getZoom()) {
|
||||
self.map.setZoom(self.minZoom);
|
||||
}
|
||||
self.$map.css({
|
||||
height: self.mapHeight + 'px',
|
||||
width: self.options.width + 'px'
|
||||
|
|
Loading…
Reference in a new issue