only call getMapBounds if loaded

This commit is contained in:
j 2014-04-11 21:08:02 +00:00
parent 0de8f278da
commit 9129908cf8

View file

@ -138,7 +138,7 @@ Ox.Map = function(options, self) {
sort: '-area'
});
}
getMapBounds(function(mapBounds) {
self.loaded && getMapBounds(function(mapBounds) {
if (mapBounds) {
self.map.fitBounds(mapBounds);
} else {
@ -714,20 +714,14 @@ Ox.Map = function(options, self) {
}
function getMapBounds(callback) {
if (!window.google) {
setTimeout(function() {
getMapBounds(callback);
}, 100);
} else {
// get initial map bounds
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)
));
});
}
// get initial map bounds
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() {