Custom Content Plugin does not work

Are you having problems with using or developing a plugin? Let me know here.
Post Reply
jaimehempke
Posts: 22
Joined: Sat Jun 09, 2012 2:06 am

Custom Content Plugin does not work

Post by jaimehempke » Wed Jun 13, 2018 1:46 pm

Good morning, I installed the new version 2.4.1 and since then the custom content plugin has stopped working, activating the map and the aircraft disappear, no matter what content I'm using, just activate the map stops working and no aircraft appears . I see that the version of it is still 2.4.0, if you have any solutions I thank you :(

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

Re: Custom Content Plugin does not work

Post by agw » Wed Jun 13, 2018 6:11 pm

You were running the version 3 preview. You can still install the v3 beta, just follow the links from the preview page.

Otherwise if you want to use 2.4.1 because of the Leaflet maps (which are not yet in version 3) then install the 2.4.0 custom content plugin from the downloads page.

T-EGJA1
Posts: 101
Joined: Sun Sep 08, 2013 12:11 am
Location: Mid-Devon, UK

Re: Custom Content Plugin does not work

Post by T-EGJA1 » Wed Jun 13, 2018 9:45 pm

.... however note that some Custom Content is incompatible with Leaflet maps, (VRS 2.4.1 with Custom Content plugin 2.4.0) e.g. I had to turn off my custom map markers (for mil airbase locations), otherwise no aircraft showed :(
Terry

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

Re: Custom Content Plugin does not work

Post by agw » Thu Jun 14, 2018 12:08 am

Custom content that uses the VRS map wrapper instead of making native Google Maps calls will work with both Google Maps and Leaflet.

There's no documentation for the wrapper but it's mostly self-explanatory. The public interface for it is at line 169 (at time of writing) here - just search for IMap:

https://github.com/vradarserver/vrs/blo ... edefs.d.ts

If you want to add a marker via the wrapper instead of via native calls then get the map from the pageSettings as you're already doing to get the native map handle and then call addMarker etc. to add markers, polylines and so on.

T-EGJA1
Posts: 101
Joined: Sun Sep 08, 2013 12:11 am
Location: Mid-Devon, UK

Re: Custom Content Plugin does not work

Post by T-EGJA1 » Thu Jun 14, 2018 12:49 am

Many thanks, Andrew - I'll give it a go :)
Terry

T-EGJA1
Posts: 101
Joined: Sun Sep 08, 2013 12:11 am
Location: Mid-Devon, UK

Re: Custom Content Plugin does not work

Post by T-EGJA1 » Fri Jun 15, 2018 1:29 pm

agw wrote:
Thu Jun 14, 2018 12:08 am
Custom content that uses the VRS map wrapper instead of making native Google Maps calls will work with both Google Maps and Leaflet.

There's no documentation for the wrapper but it's mostly self-explanatory. The public interface for it is at line 169 (at time of writing) here - just search for IMap:

https://github.com/vradarserver/vrs/blo ... edefs.d.ts

If you want to add a marker via the wrapper instead of via native calls then get the map from the pageSettings as you're already doing to get the native map handle and then call addMarker etc. to add markers, polylines and so on.
Sorry, Andrew - I've tried, but I'm struggling without success - if you can spare the time, please could you post an example of the code to add a marker via the wrapper, to help me understand the syntax?

Thanks
Terry

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

Re: Custom Content Plugin does not work

Post by agw » Fri Jun 15, 2018 9:14 pm

This adds the ADSB V0 16x16 image to the map at 51 / -0.6:

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) {
                var mapPlugin = pageSettings.mapPlugin;
                if(mapPlugin) {
                    mapPlugin.addMarker(
                        // First parameter is the ID. Must be unique. Do not clash with VRS - give it a good prefix like 'my-plugin-'.
                        // If there is already a marker with this ID then the existing marker is deleted before this one is added.
                        'my-marker-01',
                        
                        // The second parameter is the map marker settings object.
                        {
                            // Mandatory marker settings
                            position: { lat: 51, lng: -0.6 },
                            
                            // Optional marker settings.
                            // Some settings are Google-only or Leaflet-only
                            clickable: false,
                            draggable: false,
                            optimized: false,       // <-- only has an effect on Google markers, do NOT optimise if they can move
                            raiseOnDrag: false,
                            visible: true,
                            animateAdd: false,
                            zIndex: 12,

                            icon: {
                                url: 'images/adsb-0.png'
                            }
                        }
                    );
                }
            });
        });
    }
</script>

T-EGJA1
Posts: 101
Joined: Sun Sep 08, 2013 12:11 am
Location: Mid-Devon, UK

Re: Custom Content Plugin does not work

Post by T-EGJA1 » Sat Jun 16, 2018 10:41 am

Much appreciated, Andrew - I've got it working now, thanks to that example :D
Terry

Post Reply