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() {
|
function editing() {
|
||||||
var place = getSelectedPlace();
|
var place = getSelectedPlace();
|
||||||
return place && place.editing;
|
return place && place.editing;
|
||||||
|
@ -769,7 +774,13 @@ Ox.Map = function(options, self) {
|
||||||
} else if (self.options.selected) {
|
} else if (self.options.selected) {
|
||||||
selectPlace(self.options.selected, true);
|
selectPlace(self.options.selected, true);
|
||||||
} else {
|
} 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) {
|
if (self.map.getZoom() < self.minZoom) {
|
||||||
self.map.setZoom(self.minZoom);
|
self.map.setZoom(self.minZoom);
|
||||||
}
|
}
|
||||||
|
@ -801,9 +812,12 @@ Ox.Map = function(options, self) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function crossesDateline() {
|
function isEmpty(bounds) {
|
||||||
var bounds = self.map.getBounds();
|
// Google's bounds.isEmpty() is not reliable
|
||||||
return bounds.getSouthWest().lng() > bounds.getNorthEast().lng();
|
var southWest = bounds.getSouthWest(),
|
||||||
|
northEast = bounds.getNorthEast();
|
||||||
|
return southWest.lat() == northEast.lat()
|
||||||
|
&& southWest.lng() == northEast.lng();
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapChanged() {
|
function mapChanged() {
|
||||||
|
@ -1396,6 +1410,9 @@ Ox.Map = function(options, self) {
|
||||||
self.options.width = that.$element.width();
|
self.options.width = that.$element.width();
|
||||||
self.mapHeight = getMapHeight();
|
self.mapHeight = getMapHeight();
|
||||||
self.minZoom = getMinZoom();
|
self.minZoom = getMinZoom();
|
||||||
|
if (self.minZoom > self.map.getZoom()) {
|
||||||
|
self.map.setZoom(self.minZoom);
|
||||||
|
}
|
||||||
self.$map.css({
|
self.$map.css({
|
||||||
height: self.mapHeight + 'px',
|
height: self.mapHeight + 'px',
|
||||||
width: self.options.width + 'px'
|
width: self.options.width + 'px'
|
||||||
|
|
Loading…
Add table
Reference in a new issue