Second Load of Map is Failing with Latest Plugin
See original GitHub issueI’m submitting a … (check one with “x”) [ ] question [x ] any problem or bug report [ ] feature request
The plugin version: (check one with “x”) [ ] 1.4.x [x ] 2.0.0-beta3
If you choose ‘problem or bug report’, please select OS: (check one with “x”) [ ] Android [x ] iOS
cordova information: (run $> cordova plugin list
)
com.googlemaps.ios 2.3.0 "Google Maps SDK for iOS"
cordova-background-geolocation-lt 2.5.1 "BackgroundGeolocation"
cordova-plugin-actionsheet 2.2.2 "ActionSheet"
cordova-plugin-background-fetch 4.0.0 "CDVBackgroundFetch"
cordova-plugin-camera 2.3.0 "Camera"
cordova-plugin-cocoalumberjack 0.0.1 "CocoaLumberjack"
cordova-plugin-compat 1.0.0 "Compat"
cordova-plugin-console 1.0.2 "Console"
cordova-plugin-device 1.1.1 "Device"
cordova-plugin-dialogs 1.2.0 "Notification"
cordova-plugin-file 4.3.0 "File"
cordova-plugin-file-transfer 1.6.0 "File Transfer"
cordova-plugin-googlemaps 2.0.0-beta3-20170820-2025 "cordova-plugin-googlemaps"
cordova-plugin-network-information 1.2.0 "Network Information"
cordova-plugin-urlhandler 0.7.0 "URLHandler"
cordova-plugin-whitelist 1.2.1 "Whitelist"
cordova-spatialite-storage 1.1.0 "Cordova sqlite/spatialite storage plugin"
phonegap-plugin-barcodescanner 6.0.6 "BarcodeScanner"
phonegap-plugin-contentsync 1.3.5 "content-sync"
phonegap-plugin-push 1.8.1 "PushPlugin"
uk.co.workingedge.phonegap.plugin.launchnavigator 3.1.1 "Launch Navigator"
Kimberlees-MacBook-Pro:dvLinemanAppSDK2 kimberleearmstrong$ cordova plugin ls
com.googlemaps.ios 2.3.0 "Google Maps SDK for iOS"
cordova-background-geolocation-lt 2.5.1 "BackgroundGeolocation"
cordova-plugin-actionsheet 2.2.2 "ActionSheet"
cordova-plugin-background-fetch 4.0.0 "CDVBackgroundFetch"
cordova-plugin-camera 2.3.0 "Camera"
cordova-plugin-cocoalumberjack 0.0.1 "CocoaLumberjack"
cordova-plugin-compat 1.0.0 "Compat"
cordova-plugin-console 1.0.2 "Console"
cordova-plugin-device 1.1.1 "Device"
cordova-plugin-dialogs 1.2.0 "Notification"
cordova-plugin-file 4.3.0 "File"
cordova-plugin-file-transfer 1.6.0 "File Transfer"
cordova-plugin-googlemaps 2.0.0-beta3-20170820-2025 "cordova-plugin-googlemaps"
cordova-plugin-network-information 1.2.0 "Network Information"
cordova-plugin-urlhandler 0.7.0 "URLHandler"
cordova-plugin-whitelist 1.2.1 "Whitelist"
cordova-spatialite-storage 1.1.0 "Cordova sqlite/spatialite storage plugin"
phonegap-plugin-barcodescanner 6.0.6 "BarcodeScanner"
phonegap-plugin-contentsync 1.3.5 "content-sync"
phonegap-plugin-push 1.8.1 "PushPlugin"
uk.co.workingedge.phonegap.plugin.launchnavigator 3.1.1 "Launch Navigator"
Current behavior: trying to load the map the second time gives me a js console error “TypeError: null is not an object (evaluating ‘bounds.northeast’)”
Expected behavior: Before updating the plugin today this would just load the map as expected
Steps to reproduce: You can go to the bit bucket project LinemanApp. Add the latest google map plugin Start the app point it to the url if needed. (private email me if you don’t still have the url) Login goes to map works good. Click left arrow in top left of map Select “Sync Source Code” After code syncs login Now the map is broken and you get the JS console error
Screen capture or video record: http://www.youtube.com/watch?v=OvL_anj0ZKM
Related code, data or error log (please format your code or data):
Map initialization code:
/*----------------------------------------------------------------------------*/
var isTablet=true;
function initializeMap() {
if (googleMap != null) {
googleMap.remove();
}
var width = null;
var height = null;
console.log("$(window) ===== "+window.orientation+": "+$(window).width()+"X"+$(window).height());
console.log("avail ======= "+window.orientation+": "+screen.width+"X"+screen.height);
windowheight=screen.height;
windowwidth=screen.width;
isTablet = (windowheight > 1000 || windowwidth > 1000);
if ((platform == 'I' && (window.orientation == 90 || window.orientation == -90)) ||
(platform == 'A' && isTablet && (window.orientation == 0 || window.orientation == 180)) ||
(platform == 'A' && !isTablet && (window.orientation == 90 || window.orientation == -90))){ //LANDSCAPE
width = Math.max(windowheight,windowwidth);
height = Math.min(windowheight,windowwidth);
}else {
width = Math.min(windowheight,windowwidth);
height = Math.max(windowheight,windowwidth);
}
if (platform == 'A'){
height = height - 25;
width = width - 5;
}
windowheight=height;
windowwidth=width;
$('#connectionmessage').css({'top':((parseInt(windowheight)/2)-50)+'px','left':(parseInt((windowwidth)/2)-175)+'px',width:'250px'});
//$(".bottom_menu").css({'transform': 'translateZ(0)', '-webkit-transform': 'translateZ(0)', 'will-change': 'transorm'});
$(".ui-page").css({'min-height':height,'height':height,'width':width,'min-width':width});
$('#mapheader').css({'width': width,'min-width': width, position: 'absolute', left: '0px', top:ios7Pad});
if (isTablet==false) {
$("#mapfooter button").css({'margin-left':'5px'});
$("#mapheader button").css({'margin-right':'5px'});
$(".right_icon1").css({left:(width-(5+$(".right_icon3").width())*3)+'px',position:'absolute', margin:'0px', top:$(".top_icon").css('top')});
$(".right_icon2").css({left:(width-(5+$(".right_icon3").width())*2)+'px',position:'absolute', margin:'0px', top:$(".top_icon").css('top')});
$(".right_icon3").css({left:(width-5-$(".right_icon3").width())+'px',position:'absolute', margin:'0px', top:$(".top_icon").css('top')});
$("#close_container, #new_alert,#new_equipment, #chooseAddType, #addMenu, #send_message, #send_backoffice_message, #close_item, #createSoDiv, #update_container").css({margin:'0px',padding:'0px'});
$("#map_page>div button").parent().css({'max-width':'95%'});
$("#map_page>div select").parent().css({'max-width':'95%'});
$("#map_page>div textarea").css({'max-width':'95%'});
console.log('small window width');
}else{
$(".right_icon1").css({left:(width-185)+'px',position:'absolute', margin:'0px', top:$(".top_icon").css('top')});
$(".right_icon2").css({left:(width-110)+'px',position:'absolute', margin:'0px', top:$(".top_icon").css('top')});
$(".right_icon3").css({left:(width-45)+'px',position:'absolute', margin:'0px', top:$(".top_icon").css('top')});
}
$(document).find("div[data-role='popup']").on({
popupbeforeposition: function() {
googleMap.setClickable("false");
},
popupafterclose: function() {
googleMap.setClickable("true");
}
});
$('#map_canvas').css({height: (height - $("#mapheader").height() - ios7Pad - $("#mapfooter").height()) - androidFooterPad, width: width, position: 'absolute', top: ($("#mapheader").height() + ios7Pad) + 'px', left: '0px', padding:'0px', margin: '0px'});
$('#mapfooter').css({'width': width,'min-width': width, position: 'absolute', left: '0px',top: $("#map_canvas").height()+ios7Pad+$("#mapheader").height()});
//directions = plugin.google.maps.DirectionsRenderer();*/
var center = {lat:parseFloat(params.googleLat), lng:parseFloat(params.googleLon)};
console.log("creating google map with zoom:"+parseInt(params.googleZoom)+" and center of "+parseFloat(params.googleLat)+" / "+parseFloat(params.googleLon)+" Google=" +JSON.stringify(center));
var options = {
'mapType': plugin.google.maps.MapTypeId.NORMAL,
'controls': {
'compass': true,
'myLocationButton': true,
'indoorPicker': true,
'zoom': true
},
'gestures': {
'scroll': true,
'tilt': true,
'rotate': true,
'zoom': true
}
};
googleMap = plugin.google.maps.Map.getMap(document.getElementById("map_canvas"), options);
googleMap.on(plugin.google.maps.event.MAP_READY, function() {
console.log("panning google map with zoom:"+parseInt(params.googleZoom)+" and center of "+parseFloat(params.googleLat)+" / "+parseFloat(params.googleLon)+" Google=" +JSON.stringify(center));
googleMap.animateCamera( {
'target': center,
'tilt':0,
'zoom': parseInt(params.googleZoom),
'bearing':0,
'duration':2000
},
function() {
if (typeof(g_openingArgs) != 'undefined' && g_openingArgs != null ) {
loadedMapMakeCallFromOtherApp();
}
});
googleMap.on(plugin.google.maps.event.CAMERA_MOVE_END, function() {
console.log('camera idle event fired');
for (var key in googleMap.OVERLAYS) {
if (key.indexOf('groundoverlay') != -1) {
googleMap.OVERLAYS[key].remove();
}
}
mapMoved();
});
refreshGoogleMap();
if (typeof(g_openingArgs) != 'undefined' && g_openingArgs != null ) {
loadedMapMakeCallFromOtherApp();
}
});
googleMap.on(plugin.google.maps.event.MAP_CLICK, function(event) {
if ( stopFakeSearch ){
search_value={coords:{latitude:event.lat,longitude:event.lng}};
if (findType === 'customer') {
findCustomer();
} else {
findEquipment();
}
stopFakeSearch=false;
googleMap.animateCamera( {
'target': {lat:parseFloat(event.lat), lng:parseFloat(event.lng)},
'tilt':0,
'zoom': 16,
'bearing':0,
'duration':1000
},
function() {});
}else{
fakeSearch(event.lat,event.lng,googleMap.getCameraZoom());
}
});
googleMap.on(plugin.google.maps.event.MAP_LONG_CLICK, function(event) {
stopFakeSearch=true;
crewIndex=null;
search_value={coords:{latitude:event.lat,longitude:event.lng}};
if (appname == 'FieldDesign') {
addEquipment();
}else {
showDivCentered("chooseAddType");
}
});
//loadBackoffice();
}
/*----------------------------------------------------------------------------*/
function refreshGoogleMap() {
console.log("refreshGoogleMap()");
clearTimeout(map_refresh_timer);
map_refresh_timer = setTimeout(refreshGoogleMap, params.LinemanAppMapRefreshRate * 1000);
if (firstTime === true) {
firstTime = false;
}
if (g_db != null) {
g_db.abortAllPendingTransactions();
}
$("#closeBtn").trigger("click");
/*for (var key in googleMap.OVERLAYS) {
if (typeof(googleMap.OVERLAYS[key].hideInfoWindow) == "function") {
googleMap.OVERLAYS[key].hideInfoWindow();
}else{
console.log("hideInfoWindow() is not a function");
}
}*/
disconn_markers = {'SUB':[],'FDR':[],'FUSE':[],'REC':[],'SEC':[],'CAP':[],'SW':[],'TRN':[],'STEP':[],'PL':[],'PL3':[],'SL':[],'MTR':[],'POLE':[]};
if (navigator.connection.type == Connection.NONE && hasSpatialDB) {
//$("#mapheader h1").html(appname+' Map <span style="color:red;">(OFFLINE)</span>');
googleMap.clear();
setTimeout(function() {
loadDisconnectedMap();
loadMarkers(closeTicketReloadMarkers);
},500);
return;
}
if (navigator.connection.type == Connection.NONE) {
return;
}
googleMap.clear();
setTimeout(function(){
$("#waiting").hide();
loadMarkers(Object.keys(masterMarkerList));
if ($.isFunction(populateTables)) {
populateTables();
}
if (localStorage.getItem('ckbx_PrimaryLines') !== 'false') {
addPrimLineLayer();
}
if (localStorage.getItem('ckbx_Weather') !== 'false') {
addWeatherLayer();
}
},500);
}
Function called when "Sync Source Code" is clicked...
function loadJavascripts(){
console.log("loadJavascripts() from index_sdk.html");
$("#waiting").show();
$("#connectionmessage").html('Code is syncing. Please Wait...').show();
$.ajax({
type: "GET",
url: localStorage.ims_url+"/websrvrequests/mobile/ajaxZipAppSourceCode.php",
data: { appname: appname, google: localStorage.googleapi},
dataType: "jsonp",
timeout: 30000,
success: function( msg ) {
if (msg.result == false) {
alert("Failed to create zipped file of source code on server. Permission Error.");
return;
}
var zipfile = msg.zipfile;
var sync = ContentSync.sync({src:localStorage.ims_url+"/uploaded_files/LinemanApp.zip", id:"www", type:"merge", copyRootApp:true, copyCordovaAssets:true, header:false});
sync.on('progress', function(data) {
$("#connectionmessage").html('Source Sync Progress:'+data.status+" / "+data.progress+" % complete.").show();
});
sync.on('complete', function(data) {
//console.log(data.localPath);
//debugger;
$("#connectionmessage").hide();
$("#waiting").hide();
console.log("file://"+data.localPath)
////listDir("file://"+data.localPath);
//console.log(cordova.file);
ContentSync.loadUrl("file://"+data.localPath+"/index.html",
function() {
console.log("loaded new index.html");
});
//syncComplete(data);
/**/
});
sync.on('error', function(e) {
alert('Source Sync Error: ', e.message);
$("#waiting").hide();
// e.message
});
sync.on('cancel', function() {
// triggered if event is cancelled
alert("Soure Sync was Cancelled");
$("#waiting").hide();
});
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
$("#waiting").hide();
console.log(XMLHttpRequest+textStatus+errorThrown);
alert("Unable to connect to OMS using: "+$('#ims_url').val());
$("#set_settings").addClass('ui-disabled');
}
});
}
If your problem is solved, please consider small amount donation to this project. Appreciate for your kindness. https://github.com/mapsplugin/cordova-plugin-googlemaps-doc/blob/master/README.md#buy-me-a-beer
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (8 by maintainers)
Top GitHub Comments
Fixed.
Okay…