only call getMapBounds if loaded
This commit is contained in:
parent
0de8f278da
commit
9129908cf8
1 changed files with 9 additions and 15 deletions
|
@ -138,7 +138,7 @@ Ox.Map = function(options, self) {
|
||||||
sort: '-area'
|
sort: '-area'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getMapBounds(function(mapBounds) {
|
self.loaded && getMapBounds(function(mapBounds) {
|
||||||
if (mapBounds) {
|
if (mapBounds) {
|
||||||
self.map.fitBounds(mapBounds);
|
self.map.fitBounds(mapBounds);
|
||||||
} else {
|
} else {
|
||||||
|
@ -714,20 +714,14 @@ Ox.Map = function(options, self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMapBounds(callback) {
|
function getMapBounds(callback) {
|
||||||
if (!window.google) {
|
// get initial map bounds
|
||||||
setTimeout(function() {
|
self.options.places({}, function(result) {
|
||||||
getMapBounds(callback);
|
var area = result.data.area;
|
||||||
}, 100);
|
callback(new google.maps.LatLngBounds(
|
||||||
} else {
|
new google.maps.LatLng(area.south, area.west),
|
||||||
// get initial map bounds
|
new google.maps.LatLng(area.north, area.east)
|
||||||
self.options.places({}, function(result) {
|
));
|
||||||
var area = result.data.area;
|
});
|
||||||
callback(new google.maps.LatLngBounds(
|
|
||||||
new google.maps.LatLng(area.south, area.west),
|
|
||||||
new google.maps.LatLng(area.north, area.east)
|
|
||||||
));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMapHeight() {
|
function getMapHeight() {
|
||||||
|
|
Loading…
Reference in a new issue