Hi Terry and Happy Tuesday,
Generally speaking - calls out to the Google API take time... and although I'm not positive - and don't know your use case entirely - what's likely happening is the API call is still running - and your page is displaying....
What you should be sensing is if !Appery('nameofMap').gmap (ie the object is not complete) - the run a setTimeOut function to 'hang out and wait' - and then retry to see if the map exists - and - if so - do a refresh ....
Here's a code example:(note the !map - and then the function to hang out - below...)(Sorry about the extra code - but it's a quick cut and paste from one of our apps)
function fSetUserEventMap() {
map = Apperyio("mUserHistory").gmap;
if (!map) {
setDelay();
} else {
var bounds;
var sCurrentTimeStamp;
var oUserGpsPoints;
var nMarkerLng;
var nMarkerLat;
var oMarkerLatLng;
var oMarker;
var sContent;
var sTimeStamp;
var sDateStamp;
var oGpsEventsMap = JSON.parse(fLocalGet('sGpsEventsMapData'));
bounds = new google.maps.LatLngBounds();
map.set("disableDefaultUI", true);
map.set("zoomControl", true);
map.setMapTypeId('hybrid');
map.setTilt(0);
oUserGpsHistory = oGpsEventsMap;
for (var i = 0; i < oUserGpsHistory.length; i++) {
nMarkerLng = oUserGpsHistory.location[0];
nMarkerLat = oUserGpsHistory.location[1];
oMarkerLatLng = new google.maps.LatLng(nMarkerLat, nMarkerLng);
sCurrentTimeStamp = oUserGpsHistory.timestamp;
sTimeStamp = fDisplayTimeSatus(sCurrentTimeStamp, 'time');
sDateStamp = fDisplayTimeSatus(sCurrentTimeStamp, 'date');
sContent = (i + 1).toString() + "." + " " + sDateStamp + ' ' + sTimeStamp;
sContent2 = '' + (i + 1).toString() + "." + '' + '' + " Time: " + '' + '' + sDateStamp + ', ' + sTimeStamp + '' + '' + 'Location: ' + '' + '' + nMarkerLat + ', ' + nMarkerLng + '' + '' + ' Speed: ' + '' + '' + Math.round(oUserGpsHistory.speed) + '' + '' + ' Accuracy: ' + '' + '' + oUserGpsHistory.accuracy + '';
//create your marker
oStyleIcon = new StyledIcon(StyledIconTypes.MARKER, {
color: 'ffffff',
text: sContent
});
//create your marker
oMarker = new StyledMarker({
styleIcon: oStyleIcon,
position: oMarkerLatLng,
map: map,
draggable: false,
title: sContent,
});
var infowindow = new google.maps.InfoWindow({
content: sContent2
});
fAttachInfoWindow(map, oMarker, infowindow);
aMarkers.push(oMarker); // markers are now stored in the array aMarkers
bounds.extend(aMarkers.getPosition()); // make sure the bounds shows all markers
map.fitBounds(bounds); // now adjust the view
map.panToBounds(bounds); // pan to the new bounds
google.maps.event.addListener(oMarker, 'dblclick', function() {
this.map.setZoom(16);
});
} ///end of for loop
serviceFacilitiesOnGpsMap.execute();
} //end of else statemenT
return true;
}
function setDelay() {
setTimeout(fSetUserEventMap, 50);
}