Open AIP

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.
agw
Posts: 2146
Joined: Fri Feb 17, 2012 3:20 am

Re: Open AIP

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

When this kind of thing happens I generally take a look at the Network tab in the browser's developer tools (you usually get to those with F12) and look at the full URL that the browser is trying to fetch.

I the case of "/Airspace.kml" I imagine the browser will try to fetch Airspace.kml off the root of the server. That won't work because you need the prefix that VRS is using (/VirtualRadar). If you need to path it from root then try "/VirtualRadar/Airspace.kml". If the page that references the file is already at the top level of the VRS site then just remove the leading /.

However, in the script I think you need an absolute URL for google.maps.KmlLayer. I would add a function that takes a relative path and turns it into an absolute path - add this bit right at the end of the script, just before the </script> tag:

Code: Select all

function formAbsoluteUrl(relativePath)
{
    var result = window.location.href;
    var lastSlashIdx = result.lastIndexOf('/');
    return result.slice(0, lastSlashIdx) + relativePath;
}
and then where you have references to kml files replace them with calls to that function - e.g.

Code: Select all

        var ctaLayer = new google.maps.KmlLayer({
          url: 'http://webpage.com/Airports.kml',
          map: map
        });
becomes

Code: Select all

        var ctaLayer = new google.maps.KmlLayer({
          url: formAbsoluteUrl('/Airports.kml'),
          map: map
        });

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

Re: Open AIP

Post by Mac » Sun Aug 14, 2016 10:43 am

Thanks that helped a great deal. It still doesn't work on the Windows 10 machine but works on an XP machine :?
I've copied over the HTML and KML files used on the XP machine to the Win 10 machiine but it made no difference.
F12 shows a correct path to the KML file so not sure whats up, unless it a Win 10 security issue.

Any idea how to convert Airport AIP files ?
I can convert Airspace files bit the option to convert Airport AIP files in QOpen is greyed out ??

Thanks

Mac

EDDT38
Posts: 16
Joined: Thu Dec 24, 2015 3:27 pm

Re: Open AIP

Post by EDDT38 » Fri Oct 28, 2016 7:59 pm

nitro999 wrote:Here's the code to make it work using the custom content plugin. You'll need to change the URL to wherever you are hosting your KML files:

Code: Select all

<script type="text/javascript">
    if(VRS && VRS.globalDispatch && VRS.serverConfig) {
        VRS.globalDispatch.hook(VRS.globalEvent.bootstrapCreated, function(bootStrap) {
          
            if(bootStrap.hookMapInitialised) {

                bootStrap.hookMapInitialised(function(pageSettings) {

                    if(pageSettings.mapPlugin && pageSettings.mapPlugin.getNativeType() === 'GoogleMaps') {

                        var map = pageSettings.mapPlugin.getNative();
                        
                   
//Add airports layer

        var ctaLayer = new google.maps.KmlLayer({
          url: 'http://webpage.com/Airports.kml',
          map: map
        });

//Add hotspots layer

        var ctaLayer = new google.maps.KmlLayer({
          url: 'http://webpage.com/Hotspot.kml',
          map: map
        });

//Add airspace layer


        var ctaLayer = new google.maps.KmlLayer({
        url: 'http://webpage.com/Airspace.kml',
        map: map
        });



                    }
                });
            }
        });
    }
</script>
The above puts the overlay on all the time. If anyone knows how to write a function to toggle them on / off then please do let me know.

Hi,

I tried this code to put german waypoints into my map.
I created a map in google maps an saved the kml file.
In my map at Google I have got small black points for the waypoints but in VRS I have got the typical google maps marker.
What is the reason for it?
Can you help me?

Marcus

Image
Image
A3 ADS-B Antenne | FlightAware Pro Stick | 1090Mhz Filter | Raspberry Pi 2 B
Dump1090 | PiAware | VRS

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

Re: Open AIP

Post by Mac » Fri Oct 28, 2016 8:51 pm

Try this

Install the custom content plugin.
Copy the text below into a html file and setup the plugin as shown in the photo attached. ( Airspace Tiles.html in screenshot )
Any questions give me a shout.

CODE****************

<script type="text/javascript">
if(VRS && VRS.globalDispatch && VRS.serverConfig) {
VRS.globalDispatch.hook(VRS.globalEvent.bootstrapCreated, function(bootStrap) {

if(bootStrap.hookMapInitialised) {

bootStrap.hookMapInitialised(function(pageSettings) {

if(pageSettings.mapPlugin && pageSettings.mapPlugin.getNativeType() === 'GoogleMaps') {

var map = pageSettings.mapPlugin.getNative();


//Add airspace overlays

var myMapType = new google.maps.ImageMapType({
getTileUrl: function(coord, zoom) {
return "http://1.tile.maps.openaip.net/geowebca ... 00913@png/" +
zoom + "/" + coord.x + "/" + (Math.pow(2, zoom) - coord.y - 1) + ".png";
},
tileSize: new google.maps.Size(256, 256),
maxZoom: 9,
minZoom: 0,
name: 'mymaptype'
});

map.overlayMapTypes.insertAt(0, myMapType);



}
});
}
});
}
</script>

EDDT38
Posts: 16
Joined: Thu Dec 24, 2015 3:27 pm

Re: Open AIP

Post by EDDT38 » Fri Oct 28, 2016 9:53 pm

Hi Mac,

thank you, it works.
But this layer is too colorfull for me.

I tried my way again and saved the map as kmz file.
Now i have little black points, but not the same as in Google Maps and no description of the waypoints.
A3 ADS-B Antenne | FlightAware Pro Stick | 1090Mhz Filter | Raspberry Pi 2 B
Dump1090 | PiAware | VRS

DaveB771
Posts: 1
Joined: Tue Jan 10, 2017 6:07 pm

Re: Open AIP

Post by DaveB771 » Tue Jan 10, 2017 6:09 pm

hello. i have tried doing this using the code below. i have converted the files to .kml but it wont show on my own vrs. do the kml files have to be uploaded somwhere online to work as i currently directed the script to the files on my hard drive. thanks


nitro999 wrote:Here's the code to make it work using the custom content plugin. You'll need to change the URL to wherever you are hosting your KML files:

Code: Select all

<script type="text/javascript">
    if(VRS && VRS.globalDispatch && VRS.serverConfig) {
        VRS.globalDispatch.hook(VRS.globalEvent.bootstrapCreated, function(bootStrap) {
          
            if(bootStrap.hookMapInitialised) {

                bootStrap.hookMapInitialised(function(pageSettings) {

                    if(pageSettings.mapPlugin && pageSettings.mapPlugin.getNativeType() === 'GoogleMaps') {

                        var map = pageSettings.mapPlugin.getNative();
                        
                   
//Add airports layer

        var ctaLayer = new google.maps.KmlLayer({
          url: 'http://webpage.com/Airports.kml',
          map: map
        });

//Add hotspots layer

        var ctaLayer = new google.maps.KmlLayer({
          url: 'http://webpage.com/Hotspot.kml',
          map: map
        });

//Add airspace layer


        var ctaLayer = new google.maps.KmlLayer({
        url: 'http://webpage.com/Airspace.kml',
        map: map
        });



                    }
                });
            }
        });
    }
</script>
The above puts the overlay on all the time. If anyone knows how to write a function to toggle them on / off then please do let me know.

nitro999
Posts: 75
Joined: Tue Feb 09, 2016 7:32 pm
Location: UK
Contact:

Re: Open AIP

Post by nitro999 » Thu Jan 12, 2017 8:41 pm

Hello - it should work if you put the KML files in your VRS root folder. Take a look at the following page, and scroll down to the 'Site root folder' section.

http://www.virtualradarserver.co.uk/Doc ... fault.aspx
http://www.virtualradaruk.com
Radarcape, Swindon (UK) | FR24: T-EGVA10 | Flightaware 16984
adsbhub.org feeder #50 Swindon, UK

edwoodza
Posts: 1
Joined: Wed Apr 12, 2017 1:24 pm

Re: Open AIP

Post by edwoodza » Wed Apr 12, 2017 1:27 pm

bit of a nuub here sorry.
how do i impliment that code with the custom content plugin.
ie how do i enter the code (link to file) in the custom content plugin

sorry massive vertical learning curve for me currently

Swadsb
Posts: 2
Joined: Fri Oct 28, 2016 8:43 pm

Re: Open AIP

Post by Swadsb » Tue Oct 23, 2018 8:44 pm

Hi all

Has the abovementioned javascript code stopped working in newer versions of VRS / Plug in?

I have tested it on 2.4.2 / 2.4.0 but no success.

Anyone successful on this combination?

nitro999
Posts: 75
Joined: Tue Feb 09, 2016 7:32 pm
Location: UK
Contact:

Re: Open AIP

Post by nitro999 » Tue Oct 23, 2018 8:58 pm

This wont work if you’re using Leadlet maps. The code as written above works on Google maps only. See the various other recent threads for overlays using Leaflet, which include OpenAIP.
http://www.virtualradaruk.com
Radarcape, Swindon (UK) | FR24: T-EGVA10 | Flightaware 16984
adsbhub.org feeder #50 Swindon, UK

Post Reply