wait for google maps to be loaded

This commit is contained in:
j 2014-04-11 19:45:49 +00:00
parent 95e6e4c36f
commit 7bb3d5d185

View file

@ -714,14 +714,20 @@ Ox.Map = function(options, self) {
}
function getMapBounds(callback) {
// 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)
));
});
if (!self.loaded) {
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)
));
});
}
}
function getMapHeight() {
@ -1426,7 +1432,13 @@ Ox.Map = function(options, self) {
}
function zoom(z) {
self.map.setZoom(self.map.getZoom() + z);
if (!self.loaded) {
setTimeout(function() {
zoom(z);
}, 100);
} else {
self.map.setZoom(self.map.getZoom() + z);
}
}
function zoomChanged() {