Is there a way to check the readiness of Google Maps before displaying it? I'd like to show a preloader block while the Google Maps is loading.
Here is the factory code I am using:
var map = false;
var myLatlng = new google.maps.LatLng(48.6908333333, 9.14055555556);
var myOptions = {
zoom: 5,
minZoom: 2,
mapTypeId: google.maps.MapTypeId.ROADMAP,
draggableCursor:'crosshair',
zoomControl: false,
center: myLatlng,
panControl: false,
streetViewControl: false,
preserveViewport: true
}
function addMap(mapId) {
var map = new google.maps.Map(document.getElementById("map"), myOptions);
}
function getMap(mapId) {
if (!map) addMap(mapId);
return map;
}
return {
addMap: addMap,
getMap: getMap
}
And here is the code inside the controller:
$scope.map = GoogleMaps.getMap();
Appreciate your help!