Day Night Overlay

Want to post something that doesn't quite fit into the other forums? This is the place for that.
ssuttner
Posts: 8
Joined: Wed Dec 30, 2015 8:39 am
Contact:

Day Night Overlay

Post by ssuttner » Wed Dec 30, 2015 9:22 am

Hi everyone!
Can anyone help to show Day Night overlay in a map ?
Here I found information about:
https://code.google.com/p/google-maps-u ... /Libraries
http://plus.martinmatysiak.de/daynightoverlay/examples/
Is it possible with the Custom Content Plugin?

agw
Posts: 2249
Joined: Fri Feb 17, 2012 3:20 am

Re: Day Night Overlay

Post by agw » Fri Jan 01, 2016 5:11 am

You can do it with the custom content plugin.

First of all you need to download the daynightoverlay.js file from the site you linked and save it in a folder somewhere. Go into the Custom Content plugin and set Site root folder to the folder where you saved daynightoverlay.js.

Then create a file somewhere called daynightoverlay.html (doesn't matter where) and copy this into it:

Code: Select all

<script type="text/javascript">
    if(VRS && VRS.globalDispatch && VRS.serverConfig) {
        VRS.globalDispatch.hook(VRS.globalEvent.bootstrapCreated, function(bootStrap) {
            bootStrap.hookInitialised(function(pageSettings) {
                // Load the daynightoverlay.js script - it throws a hissy fit if Google Maps isn't already loaded by the time
                // it gets loaded so we need to load it dynamically after Google Maps has been loaded.
                // We can't just have a <script> tag for it.
                
                if(pageSettings.mapPlugin && pageSettings.mapPlugin.getNativeType() === 'GoogleMaps') {
                    VRS.scriptManager.loadScript({
                        key: 'daynightoverlay',
                        url: 'daynightoverlay.js',
                        success: function() {
                            var map = pageSettings.mapPlugin.getNative();
                            var overlay = new DayNightOverlay({
                                map: map
                            });
                        }
                    });
                }
            });
        });
    }
</script>
In the custom content plugin options click New. Enter the full path and filename for your daynightoverlay.html file into Inject file. Enter * (i.e. just an asterisk) into Address. Click OK.

ssuttner
Posts: 8
Joined: Wed Dec 30, 2015 8:39 am
Contact:

Re: Day Night Overlay

Post by ssuttner » Fri Jan 01, 2016 12:11 pm

Happy new year, agw and thank you for your support!

I followed your instructions and downloaded first of all the wrong daynightoverlay.js from git repostory.
After this I downloaded the correct daynightoverlay.js via the second link and all works fine!

GregoryGHarding
Posts: 96
Joined: Mon Jan 26, 2015 9:01 am
Location: CYYT

Re: Day Night Overlay

Post by GregoryGHarding » Tue Jan 05, 2016 12:15 pm

the issue i have with this overlay is that it will only update when you zoom in or out.

is there a way to have this update ex 1 update per second

ssuttner
Posts: 8
Joined: Wed Dec 30, 2015 8:39 am
Contact:

Re: Day Night Overlay

Post by ssuttner » Tue Jan 05, 2016 3:29 pm

Had the same issue and can not solve it , therefore I switched to an other overlay: https://github.com/rossengeorgiev/nite-overlay
With it exists a refresh method...

Content of my nite-overlay.html:

Code: Select all

<script type="text/javascript">
    if(VRS && VRS.globalDispatch && VRS.serverConfig) {
        VRS.globalDispatch.hook(VRS.globalEvent.bootstrapCreated, function(bootStrap) {
            bootStrap.hookInitialised(function(pageSettings) {
                // Load the nite-overlay.js script copy from https://github.com/rossengeorgiev/nite-overlay
                // it gets loaded so we need to load it dynamically after Google Maps has been loaded.
                // We can't just have a <script> tag for it.
                
                if(pageSettings.mapPlugin && pageSettings.mapPlugin.getNativeType() === 'GoogleMaps') {
                    VRS.scriptManager.loadScript({
                        key: 'nite-overlay',
                        url: 'nite-overlay.js',
                        success: function() {
                            var map = pageSettings.mapPlugin.getNative();
                            nite.init(map);
                            setInterval(function() { nite.refresh() }, 10000); // every 10s
                        }
                    });
                }
            });
        });
    }
</script>

GregoryGHarding
Posts: 96
Joined: Mon Jan 26, 2015 9:01 am
Location: CYYT

Re: Day Night Overlay

Post by GregoryGHarding » Fri Jan 08, 2016 7:04 pm

awesome, thanks!

Mac
Posts: 84
Joined: Tue Mar 19, 2013 11:49 am

Re: Day Night Overlay

Post by Mac » Fri Aug 12, 2016 11:40 am

Thanks for the instructions above, they appear quite simple but I can't seem to get it to work.
I'm using Windows 10 and the V2.4 of VRS and the Custom Content plugin.

I can get a "TEST" Dialog box to popup using the custom content plugin as per the documentation but unfortunately that about all I can manage. :cry:

I have downloaded the above javascript file (nite-overlay.js ) and code and set it up as per the clearly defined instructions above but I dont seem to get the overlay to work ( even when i zoom out )
I've checked that it is enabled :)
My html file is in user/documents
My Site root folder is in same location.

Any help ?

Mac

agw
Posts: 2249
Joined: Fri Feb 17, 2012 3:20 am

Re: Day Night Overlay

Post by agw » Sat Aug 13, 2016 11:58 pm

I've just given it a go and it's working for me under 2.4 and Google Maps 3.24.

I'm wondering whether you're trying to inject the JavaScript file instead of the HTML file? Inject the HTML and make sure that the JavaScript is in the site root folder that you've specified in the custom content plugin's options.

Mac
Posts: 84
Joined: Tue Mar 19, 2013 11:49 am

Re: Day Night Overlay

Post by Mac » Sun Aug 14, 2016 8:38 am

Hi,

Its seeing the nite-overlay.js on http://www.airwavesireland.com but when I look at the F12 options and response its saying

/*
Minifier errors:
MinifyJavaScript(5,1-2): error JS1195: Expected expression: <
MinifyJavaScript(12,39-40): error JS1197: Too many errors. The file might not be a JScript .NET file: =

Also

Uncaught ReferenceError: nite is not defined

:oops: :oops:
My HTML file is being injected and I have note-overlay.js in the Site root folder.

Code: Select all

<script type="text/javascript">
    if(VRS && VRS.globalDispatch && VRS.serverConfig) {
        VRS.globalDispatch.hook(VRS.globalEvent.bootstrapCreated, function(bootStrap) {
            bootStrap.hookInitialised(function(pageSettings) {
                // Load the nite-overlay.js script copy from https://github.com/rossengeorgiev/nite-overlay
                // it gets loaded so we need to load it dynamically after Google Maps has been loaded.
                // We can't just have a <script> tag for it.
                
                if(pageSettings.mapPlugin && pageSettings.mapPlugin.getNativeType() === 'GoogleMaps') {
                    VRS.scriptManager.loadScript({
                        key: 'nite-overlay',
                        url: 'nite-overlay.js',
                        success: function() {
                            var map = pageSettings.mapPlugin.getNative();
                            nite.init(map);
                            setInterval(function() { nite.refresh() }, 10000); // every 10s
                        }
                    });
                }
            });
        });
    }
</script

ssuttner
Posts: 8
Joined: Wed Dec 30, 2015 8:39 am
Contact:

Re: Day Night Overlay

Post by ssuttner » Mon Aug 15, 2016 12:27 am

Hi,
until just I used V1.4 nite-overlay.js.
But now I switched to V1.5.
I also use V2.4 from VirtualRadarServer with Windows 10 64 bit for testing and the mono Version for my web site on raspberry pi 3 (http://www.wkdg.de/vr) and everything works fine.

I can not find a issue with your injected html (http://www.airwavesireland.com).

Please have a look to the description: https://wkdg.de/#title45
Hopefully it will help.

Post Reply