HCStrike Posted August 11, 2017 Report Share Posted August 11, 2017 Hello, I use smartCARS for my acars tracker and I was flying a flight just for a test and for some reason the live flight tracker wasn't loading. Does anyone know of any code that I need to add/change so it will work? Thanks Quote Link to comment Share on other sites More sharing options...
web541 Posted August 11, 2017 Report Share Posted August 11, 2017 If it isn't showing up (or showing as a white screen), can you please check your browser console (right click, inspect element => console) and post any errors. If the map is loading but there are no flights showing, then enable and check your logging for any DB errors. Quote Link to comment Share on other sites More sharing options...
HCStrike Posted August 11, 2017 Author Report Share Posted August 11, 2017 5 minutes ago, web541 said: If it isn't showing up (or showing as a white screen), can you please check your browser console (right click, inspect element => console) and post any errors. If the map is loading but there are no flights showing, then enable and check your logging for any DB errors. To be honest, they are both an issue, my map only loads after a refresh of my page and No flights show in the map, I'll try the error logging but you can reference this post for the map not loading https://stackoverflow.com/questions/45627716/google-maps-not-appearing-until-refresh Quote Link to comment Share on other sites More sharing options...
web541 Posted August 11, 2017 Report Share Posted August 11, 2017 For the "google is not defined" error, try replacing the contents of your core_htmlhead.php file with this https://raw.githubusercontent.com/DavidJClark/phpvms_5.5.x/master/core/templates/core_htmlhead.php And then replace this line <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script> With this one <script async defer src="http://maps.googleapis.com/maps/api/js?key=YOURKEYHERE" type="text/javascript"></script> And replace YOURKEYHERE with your Google Maps API Key (from their dev console). Remove any google maps <script> from your layout.php file (keep it in core_htmlhead). Just remember to keep the order of the lines correct and don't move any around otherwise it will screw up the loading sequence. Quote Link to comment Share on other sites More sharing options...
HCStrike Posted August 11, 2017 Author Report Share Posted August 11, 2017 1 minute ago, web541 said: For the "google is not defined" error, try replacing the contents of your core_htmlhead.php file with this https://raw.githubusercontent.com/DavidJClark/phpvms_5.5.x/master/core/templates/core_htmlhead.php And then replace this line <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script> With this one <script async defer src="http://maps.googleapis.com/maps/api/js?key=YOURKEYHERE" type="text/javascript"></script> And replace YOURKEYHERE with your Google Maps API Key (from their dev console). Remove any google maps <script> from your layout.php file (keep it in core_htmlhead). Just remember to keep the order of the lines correct and don't move any around otherwise it will screw up the loading sequence. This is what is in my core_htmlhead.php file <script async defer src="http://maps.googleapis.com/maps/api/js?key=MY_KEY" type="text/javascript"></script> Quote Link to comment Share on other sites More sharing options...
HCStrike Posted August 11, 2017 Author Report Share Posted August 11, 2017 I dont think it is a problem with my KEY as the map loads after I refresh the page Quote Link to comment Share on other sites More sharing options...
web541 Posted August 11, 2017 Report Share Posted August 11, 2017 1 minute ago, HCStrike said: I dont think it is a problem with my KEY as the map loads after I refresh the page Yeah that's correct, just confirm you've got flights going at the moment? And check the logs to see if there is any data being populated. Also, in your hosting, go to phpmyadmin and check the phpvms_acarsdata table and see if there are any rows populated. Quote Link to comment Share on other sites More sharing options...
HCStrike Posted August 11, 2017 Author Report Share Posted August 11, 2017 5 minutes ago, web541 said: Yeah that's correct, just confirm you've got flights going at the moment? And check the logs to see if there is any data being populated. Also, in your hosting, go to phpmyadmin and check the phpvms_acarsdata table and see if there are any rows populated. I don't have flights running at the moment but yesterday I did and the flight didn't show up. There is nothing in the logs at the moment but I set the logging to 2 so I changed it to 1 and I'll try a flight Quote Link to comment Share on other sites More sharing options...
web541 Posted August 11, 2017 Report Share Posted August 11, 2017 Yeah, the logs will only show if there are flights active. Quote Link to comment Share on other sites More sharing options...
HCStrike Posted August 11, 2017 Author Report Share Posted August 11, 2017 1 minute ago, web541 said: Yeah, the logs will only show if there are flights active. But shouldn't the logs show from what I had yesterday? Quote Link to comment Share on other sites More sharing options...
web541 Posted August 11, 2017 Report Share Posted August 11, 2017 1 hour ago, HCStrike said: But shouldn't the logs show from what I had yesterday? No, if your debugging logs were not enabled in the local.config.php file, then the logs won't record anything until they are enabled, so you would have to wait until yo have enabled them and you've started a flight. Quote Link to comment Share on other sites More sharing options...
HCStrike Posted August 11, 2017 Author Report Share Posted August 11, 2017 2 minutes ago, web541 said: No, if your debugging logs were not enabled in the local.config.php file, then the logs won't record anything until they are enabled, so you would have to wait until yo have enabled them and you've started a flight. They were enabled but they were enabled on 2 instead of 1. Also do you know how I can fix the map not loading until I refresh the page Quote Link to comment Share on other sites More sharing options...
web541 Posted August 11, 2017 Report Share Posted August 11, 2017 48 minutes ago, HCStrike said: They were enabled but they were enabled on 2 instead of 1. Also do you know how I can fix the map not loading until I refresh the page Yes, go to lib/js/acarsmap.js and replace all its contents with this https://raw.githubusercontent.com/DavidJClark/phpvms_5.5.x/master/lib/js/acarsmap.js And see if that works. If it breaks your map center, then we can fix that later. Quote Link to comment Share on other sites More sharing options...
HCStrike Posted August 11, 2017 Author Report Share Posted August 11, 2017 3 minutes ago, web541 said: Yes, go to lib/js/acarsmap.js and replace all its contents with this https://raw.githubusercontent.com/DavidJClark/phpvms_5.5.x/master/lib/js/acarsmap.js And see if that works. If it breaks your map center, then we can fix that later. Nope, still getting this error Uncaught ReferenceError: google is not defined at acarsmap.js:30 Quote Link to comment Share on other sites More sharing options...
web541 Posted August 11, 2017 Report Share Posted August 11, 2017 In your acarsmap.php file, find this center: new google.maps.LatLng("50.007739", "9.580078"), Replace it with this center: new google.maps.LatLng(50.007739, 9.580078), See if that works Quote Link to comment Share on other sites More sharing options...
HCStrike Posted August 11, 2017 Author Report Share Posted August 11, 2017 2 minutes ago, web541 said: In your acarsmap.php file, find this center: new google.maps.LatLng("50.007739", "9.580078"), Replace it with this center: new google.maps.LatLng(50.007739, 9.580078), See if that works Nope, still only works after a refresh Quote Link to comment Share on other sites More sharing options...
web541 Posted August 11, 2017 Report Share Posted August 11, 2017 Nope, you've done it in the wrong file. Follow these steps: Go to lib/js/acarsmap.js and replace all content with this https://raw.githubusercontent.com/DavidJClark/phpvms_5.5.x/master/lib/js/acarsmap.js Go to lib/skins/YOURSKINNAME/acarsmap.php find this <script type="text/javascript"> var acars_map_defaults = { autozoom: true, zoom: 4, center: new google.maps.LatLng("50.007739", "9.580078"), mapTypeId: google.maps.MapTypeId.TERRAIN, refreshTime: 10000 }; </script> And replace it with this <script type="text/javascript"> var acars_map_defaults = { autozoom: true, zoom: 4, center: new google.maps.LatLng("<?php echo Config::Get('MAP_CENTER_LAT'); ?>", "<?php echo Config::Get('MAP_CENTER_LNG'); ?>"), mapTypeId: google.maps.MapTypeId.TERRAIN, refreshTime: 10000 }; </script> Go to core/local.config.php and find these (or similar) Config::Set('MAP_CENTER_LAT', '45.484400'); Config::Set('MAP_CENTER_LNG', '-62.334821'); And replace it with these Config::Set('MAP_CENTER_LAT', '50.007739'); Config::Set('MAP_CENTER_LNG', '9.580078'); Check the outcome Quote Link to comment Share on other sites More sharing options...
HCStrike Posted August 11, 2017 Author Report Share Posted August 11, 2017 3 minutes ago, web541 said: Nope, you've done it in the wrong file. Follow these steps: Go to lib/js/acarsmap.js and replace all content with this https://raw.githubusercontent.com/DavidJClark/phpvms_5.5.x/master/lib/js/acarsmap.js Go to lib/skins/YOURSKINNAME/acarsmap.php find this <script type="text/javascript"> var acars_map_defaults = { autozoom: true, zoom: 4, center: new google.maps.LatLng("50.007739", "9.580078"), mapTypeId: google.maps.MapTypeId.TERRAIN, refreshTime: 10000 }; </script> And replace it with this <script type="text/javascript"> var acars_map_defaults = { autozoom: true, zoom: 4, center: new google.maps.LatLng("<?php echo Config::Get('MAP_CENTER_LAT'); ?>", "<?php echo Config::Get('MAP_CENTER_LNG'); ?>"), mapTypeId: google.maps.MapTypeId.TERRAIN, refreshTime: 10000 }; </script> Go to core/local.config.php and find these (or similar) Config::Set('MAP_CENTER_LAT', '45.484400'); Config::Set('MAP_CENTER_LNG', '-62.334821'); And replace it with these Config::Set('MAP_CENTER_LAT', '50.007739'); Config::Set('MAP_CENTER_LNG', '9.580078'); Check the outcome I've done all that and it is still the same problem Quote Link to comment Share on other sites More sharing options...
web541 Posted August 11, 2017 Report Share Posted August 11, 2017 Can you please replace all content in lib/js/acarsmap.js with this https://raw.githubusercontent.com/DavidJClark/phpvms_5.5.x/master/lib/js/acarsmap.js I can see that you have not done it yet, the rest seems to be fine. Can you also try removing this out of lib/skins/YOURSKINNAME/acarsmap.php <script type="text/javascript"> var acars_map_defaults = { autozoom: true, zoom: 4, center: new google.maps.LatLng("<?php echo Config::Get('MAP_CENTER_LAT'); ?>", "<?php echo Config::Get('MAP_CENTER_LNG'); ?>"), mapTypeId: google.maps.MapTypeId.TERRAIN, refreshTime: 10000 }; </script> But please copy the contents of the above first, that will fix one error, you seem to have overwritten it in a step above. Quote Link to comment Share on other sites More sharing options...
HCStrike Posted August 11, 2017 Author Report Share Posted August 11, 2017 (edited) 4 minutes ago, web541 said: Can you please replace all content in lib/js/acarsmap.js with this https://raw.githubusercontent.com/DavidJClark/phpvms_5.5.x/master/lib/js/acarsmap.js I can see that you have not done it yet, the rest seems to be fine. Can you also try removing this out of lib/skins/YOURSKINNAME/acarsmap.php <script type="text/javascript"> var acars_map_defaults = { autozoom: true, zoom: 4, center: new google.maps.LatLng("<?php echo Config::Get('MAP_CENTER_LAT'); ?>", "<?php echo Config::Get('MAP_CENTER_LNG'); ?>"), mapTypeId: google.maps.MapTypeId.TERRAIN, refreshTime: 10000 }; </script> But please copy the contents of the above first, that will fix one error, you seem to have overwritten it in a step above. I have replaced the content of the acarsmap.js and also removed the required code, still the same and now the map doesnt appear at all Edited August 11, 2017 by HCStrike Quote Link to comment Share on other sites More sharing options...
web541 Posted August 11, 2017 Report Share Posted August 11, 2017 Ok thanks, that gives me a better idea. Try placing this in lib/skins/YOURSKINNAME/acarsmap.php <script type="text/javascript"> var acars_map_defaults = { autozoom: true, zoom: 4, mapTypeId: google.maps.MapTypeId.TERRAIN, refreshTime: 10000 }; </script> Without the center, it might fix it. At the moment, it is still looking for the 'defaults'. Quote Link to comment Share on other sites More sharing options...
HCStrike Posted August 11, 2017 Author Report Share Posted August 11, 2017 1 minute ago, web541 said: Ok thanks, that gives me a better idea. Try placing this in lib/skins/YOURSKINNAME/acarsmap.php <script type="text/javascript"> var acars_map_defaults = { autozoom: true, zoom: 4, mapTypeId: google.maps.MapTypeId.TERRAIN, refreshTime: 10000 }; </script> Without the center, it might fix it. At the moment, it is still looking for the 'defaults'. Done that and its brought back the same errors Quote Link to comment Share on other sites More sharing options...
web541 Posted August 11, 2017 Report Share Posted August 11, 2017 (edited) First try removing this line mapTypeId: google.maps.MapTypeId.TERRAIN, Also try replacing your <script> (the one with the api key) with https:// instead of http:// Also try this link <script type="text/javascript" src="https://maps.google.com/maps/api/js?key=YOUR_KEY_HERE&sensor=true"></script> Edited August 11, 2017 by web541 Quote Link to comment Share on other sites More sharing options...
HCStrike Posted August 11, 2017 Author Report Share Posted August 11, 2017 1 hour ago, web541 said: First try removing this line mapTypeId: google.maps.MapTypeId.TERRAIN, Also try replacing your <script> (the one with the api key) with https:// instead of http:// Also try this link <script type="text/javascript" src="https://maps.google.com/maps/api/js?key=YOUR_KEY_HERE&sensor=true"></script> I've made all those changes and it is still the same error, although there is a new warning saying sensor is not required Quote Link to comment Share on other sites More sharing options...
web541 Posted August 11, 2017 Report Share Posted August 11, 2017 Ok I was able to reproduce this error. Try the following: Go to lib/skins/crewcenter/core_htmlhead.php and change your google maps api reference to this <script src="https://maps.googleapis.com/maps/api/js?key=YOURKEYHERE"></script> Notice there's no async defer in the script reference as it is waiting to asynchronous load the map via the &callback function, because phpVMS is programmed in a way that it loads after the page, not with it (i.e. there's no function init() to load). This seemed to fix it for me. Also in lib/skins/crewcenter/acarsmap.php add this back in <script type="text/javascript"> var acars_map_defaults = { autozoom: true, zoom: 4, center: new google.maps.LatLng("<?php echo Config::Get('MAP_CENTER_LAT'); ?>", "<?php echo Config::Get('MAP_CENTER_LNG'); ?>"), mapTypeId: google.maps.MapTypeId.TERRAIN, refreshTime: 10000 }; </script> And it should be fixed, report any further issues back here. 1 Quote Link to comment Share on other sites More sharing options...
HCStrike Posted August 12, 2017 Author Report Share Posted August 12, 2017 5 hours ago, web541 said: Ok I was able to reproduce this error. Try the following: Go to lib/skins/crewcenter/core_htmlhead.php and change your google maps api reference to this <script src="https://maps.googleapis.com/maps/api/js?key=YOURKEYHERE"></script> Notice there's no async defer in the script reference as it is waiting to asynchronous load the map via the &callback function, because phpVMS is programmed in a way that it loads after the page, not with it (i.e. there's no function init() to load). This seemed to fix it for me. Also in lib/skins/crewcenter/acarsmap.php add this back in <script type="text/javascript"> var acars_map_defaults = { autozoom: true, zoom: 4, center: new google.maps.LatLng("<?php echo Config::Get('MAP_CENTER_LAT'); ?>", "<?php echo Config::Get('MAP_CENTER_LNG'); ?>"), mapTypeId: google.maps.MapTypeId.TERRAIN, refreshTime: 10000 }; </script> And it should be fixed, report any further issues back here. That seems to have done the job, thank you very much 1 Quote Link to comment Share on other sites More sharing options...
web541 Posted August 12, 2017 Report Share Posted August 12, 2017 Glad to help! Quote Link to comment Share on other sites More sharing options...
HCStrike Posted August 12, 2017 Author Report Share Posted August 12, 2017 10 hours ago, web541 said: Glad to help! So the map works but I still cannot see any flights on it, there is a flight running at the moment and it is not showing on my map. There are no entries in the logs, I am using smartCARS Quote Link to comment Share on other sites More sharing options...
Virtualei Posted August 12, 2017 Report Share Posted August 12, 2017 This sounds like an error I had also. Are you using Crewcenter and by any chance do you have a weather map on the same page Quote Link to comment Share on other sites More sharing options...
HCStrike Posted August 12, 2017 Author Report Share Posted August 12, 2017 Just now, AJCWebServices said: This sounds like an error I had also. Are you using Crewcenter and by any chance do you have a weather map on the same page I am using the crewcenter but no I do not have a weather map Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.