Expose aircraftMarkerMovingMapOn to live map

The "to-do" list for Virtual Radar Server is as long as my arm, but if you want to pile more work onto it then this is for you.
Post Reply
Bhaal
Posts: 37
Joined: Wed Aug 12, 2015 10:20 am

Expose aircraftMarkerMovingMapOn to live map

Post by Bhaal » Sat Jan 16, 2016 3:03 pm

Hi agw,

Just wondering if there is a way I can change the aircraftMarkerMovingMapOn setting from the website, OR what JS variable is changed which might be checked regularly during runtime?

I want to be able to turn it on/off from a tickbox on the map, I'm happy if something down the track breaks and it needs changing again :)

Thanks

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

Re: Expose aircraftMarkerMovingMapOn to live map

Post by agw » Sat Jan 16, 2016 3:47 pm

You need to hook the bootstrap's page initialised event and then from there you just need to fish out the reference to the aircraft plotter object. Then you can just call getMovingMap() and setMovingMap(bool) on the aircraft plotter.

If you have a script like this:

Code: Select all

<script type="text/javascript">
    if(VRS && VRS.globalDispatch) {
        VRS.globalDispatch.hook(VRS.globalEvent.bootstrapCreated, function(bootStrap) {
            bootStrap.hookInitialised(function(pageSettings) {
                vrsAircraftPlotter = pageSettings.aircraftPlotter;
            });
        });
    }
    
    var vrsAircraftPlotter;

    function getMovingMapState()
    {
        return vrsAircraftPlotter ? vrsAircraftPlotter.getMovingMap() : false;
    }
    
    function setMovingMapState(onOff)
    {
        if(vrsAircraftPlotter) {
            vrsAircraftPlotter.setMovingMap(onOff);
        }
    }
</script>
Then you should be able to call the global getMovingMapState function to find out whether your checkbox should be ticked or not (this won't work until after the page has been initialised though, so you might want to do the bit to add your checkbox in the hookInitialised() method) and setMovingMapState to switch the moving map on and off.

Bhaal
Posts: 37
Joined: Wed Aug 12, 2015 10:20 am

Re: Expose aircraftMarkerMovingMapOn to live map

Post by Bhaal » Sat Jan 16, 2016 4:33 pm

agw,

You are too nice to people! :) You should have at first said "You know if you click on Menu -> Shortcuts -> Moving Map .. you will find what you are looking for." And then maybe offered to help further if that wasn't what I wanted in a later reply. I would have settled for that and saved you some time replying, but now that I have the tickbox on the map and spent all this time pawing over code and so forth, I might as well make it work :)

Thanks heaps though, it's very much appreciated!!

Cameron

Post Reply