Closed marcus-aa closed 1 year ago
Why don't you just add the 'new way' to a leaflet layer control button and then suppress the Map Layer menu item with the customs script from here https://github.com/vradarserver/vrs-custom-scripts.
This is what I have done, it works well and allows additions of additional user controllable layers and base maps.
I wasn't aware that OpenAIP had changed their API. Unfortunately it looks like they now need an API key, which VRS isn't collecting or sending. I've removed the layer from the default set of tile providers and layers, if people want to add the layer then they'll need to obtain an API key from OpenAIP, then add the OpenAIP layer as a custom layer in their configuration folder and then add a custom script to send the key in a header. It's going to be a bit of a schlep.
I can add an example custom script to show how it's done but there's a separate repository for those (https://github.com/vradarserver/vrs-custom-scripts). I'll close this one as not a VRS issue.
Thanks, but I know how it is done as a plugin, with an API key etc, I was asking about re-using the menu item. But maybe it is better to remove it to avoid confusion and do the layers as @rikgale suggested, looking at that now.
You don't need a plugin to add a custom layer, it's done via a text file in the configuration folder called TileServerSettings-Custom.json
. The name predates the addition of support for custom layers as well as tile servers. There is a text file in the configuration folder that explains the format of the file.
If you add it as a custom layer then it will be indistinguishable from the original openAIP layer. It will appear in the same layers menu as all of the other layers (including the now defunct openAIP layer) and you'll be able to toggle it on & off and change its opacity etc.
However, the custom tile servers (and layers) only support anonymous access. Hence the need for a custom script to add the API key header to requests to the tile server when the layer is switched on.
Since the old OpenAIP implementation stopped working I am using the "new" way using the method described here:
https://groups.google.com/g/openaip/c/sG8GlccNS6w/m/U8OJiGGHAgAJ
But this sets AIP permanently on for all users while the old version could be user set.
So, can the users setting of the menu (that does nothing now) be read and used as a boolean in the executing of the injection of AIP data, so it again becomes user selectable?
There is already a condition on the used map type, so maybe something similar?
if (pageSettings.mapPlugin && pageSettings.mapPlugin.getNativeType() === 'OpenStreetMap')
Thanks!