From 9129908cf8c747b4be11aa136163a19213b07fc4 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 11 Apr 2014 21:08:02 +0000 Subject: [PATCH] only call getMapBounds if loaded --- source/Ox.UI/js/Map/Map.js | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/source/Ox.UI/js/Map/Map.js b/source/Ox.UI/js/Map/Map.js index 7693f60a..a482afcf 100644 --- a/source/Ox.UI/js/Map/Map.js +++ b/source/Ox.UI/js/Map/Map.js @@ -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() {