Is Virtual Radar Server not behaving itself? If so then please report it here.
Posts: 55
Joined: Fri Nov 08, 2013 3:39 pm

Re: "Species"

Post by egpd1701 »

Create an html file called e.g. ChangeLogos.html

Add the code below

Code: Select all

<script type="text/javascript">
    if(VRS && VRS.globalDispatch && VRS.serverConfig) {
        VRS.globalDispatch.hook(VRS.globalEvent.bootstrapCreated, function(bootStrap) {
            if(VRS.renderPropertyHandlers) {
                // Overwrite the standard operator flag renderer with a custom one.
                VRS.renderPropertyHandlers[VRS.RenderProperty.Silhouette] = new VRS.RenderPropertyHandler({
                    property:               VRS.RenderProperty.Silhouette,
                    surfaces:               VRS.RenderSurface.List + VRS.RenderSurface.DetailHead + VRS.RenderSurface.InfoWindow,
                    headingKey:             'ListOperator',
                    labelKey:               'Operator',
                    sortableField:          VRS.AircraftListSortableField.OperatorIcao,
                    headingAlignment:       VRS.Alignment.Centre,
                    suppressLabelCallback:  function() { return true; },
                    fixedWidth:             function() { return VRS.globalOptions.aircraftOperatorFlagSize.width.toString() + 'px'; },
                    // Changed the following line to redraw the flag if the manufacturer changes...
                    hasChangedCallback:     function(aircraft) { return aircraft.modelIcao.chg || aircraft.icao.chg || aircraft.registration.chg || aircraft.manufacturer.chg; },
                    // And changed this line to call our custom function to build the <img> tag instead of the standard one...
                    renderCallback:         function(aircraft) { return customFormatTypeIcaoImageHtml(aircraft); },
                    tooltipChangedCallback: function(aircraft) { return aircraft.modelIcao.chg || aircraft.operator.chg; },
                    tooltipCallback:        function(aircraft) { return aircraft.formatModelIcaoNameAndDetail(); }
    function customFormatTypeIcaoImageHtml(aircraft)
        var codeToUse = '';
		codeToUse = customPipeSeparatedCode(codeToUse, aircraft.modelIcao.val + '-' + aircraft.operatorIcao.val);
		codeToUse = customPipeSeparatedCode(codeToUse, aircraft.modelIcao.val);
        codeToUse = customPipeSeparatedCode(codeToUse, aircraft.manufacturer.val);
        codeToUse = customPipeSeparatedCode(codeToUse, aircraft.operatorIcao.val);
        codeToUse = customPipeSeparatedCode(codeToUse, aircraft.registration.val);
        codeToUse = customPipeSeparatedCode(codeToUse, aircraft.icao.val);

        // The rest of this was copied from format.js operatorIcaoImageHtml()
        var size = VRS.globalOptions.aircraftOperatorFlagSize;
        var result = '<img src="images/File-' + encodeURIComponent(codeToUse)
        if(VRS.browserHelper.isHighDpi()) result += '/HiDpi';
        result += '/Type.png"' +
            ' width="' + size.width.toString() + 'px"' +
            ' height="' + size.height.toString() + 'px"' +
            ' />';

        return result;

    function customPipeSeparatedCode(text, code)
        var result = text;
        if(code && code.length) {
            if(result.length) result += '|';
            result += code;

        return result;
add the custom content file info

Enabled - Yes
Inject - ChangeLogos.html
At - Head
Of - End
Address - /desktop.html

Change your site root folder and Resource image folder to where your custom files are
Posts: 11
Joined: Sat Oct 15, 2016 10:14 pm

Re: "Species"

Post by batrakiu »

It's done... 8-)
You were sweet..! ahah

Just had to change the code to my own case.

Code: Select all

codeToUse = customPipeSeparatedCode(codeToUse, aircraft.operatorIcao.val + '' + aircraft.modelIcao.val);
No dash and change the order.

A big "thank you" to you!

Posts: 25
Joined: Sun Jun 05, 2016 9:57 am

Re: "Species"

Post by skaw »

I am trying to understand all of this, but its pretty difficult...

This last script here won't help me with the following situation, will it?

I created a new non ICAO conform Silhouette BMP for the Airbus Helicopters H145. The ICAO conform Model Code would be EC45 but since earlier EC45 Models did not have the Fenestron i decided to create a new one which matches the actual Silhouette. Of course i can place this new Silhouette BMP in the corresponding folder, set the Model Code to H145 and it takes the correct BMP file, BUT this kills the species and does not show a helicopter marker on the map anymore..

Will the script above work for this case since the model code change does not affect the operator or anything else? What would i have to call the BMPs to let every H145 use the H145 Silhouette for display but EC45 for defining the Species? and what database changes would be needed for that?


could this somehow work if " matches: function (aircraft) { return aircraft.species.val === VRS.Species.Helicopter && aircraft.isMilitary.val; }" is somehow determined by the model code?

Code: Select all

new VRS.AircraftMarker({
            normalFileName: 'gHelicopter.png',
            selectedFileName: 'Helicopter-Selected.png',
            size: { width: 32, height: 32 },
            matches: function (aircraft) { return aircraft.species.val === VRS.Species.Helicopter && aircraft.isMilitary.val; }
Posts: 2250
Joined: Fri Feb 17, 2012 3:20 am

Re: "Species"

Post by agw »

The script you're looking at sets up conditions for showing different aircraft markers. Presumably you want to have H145 as the model ICAO and still have it show a helicopter marker? You could do that by changing the aircraft marker scripts, however H145 will still not be recognised as a helicopter species.

When VRS looks for a silhouette it looks first for a file named after the aircraft's ICAO, then it's registration and finally the model type ICAO. If there are a manageably small number of these aircraft then you could just create multiple copies of the silhouette and name them after the registration, e.g. G-ABCD.bmp. You could then leave the model type as the proper ICAO code.
Posts: 25
Joined: Sun Jun 05, 2016 9:57 am

Re: "Species"

Post by skaw »

Okay, will need to use the ICAO since it does not work with the registration for some reason. Thanks for the tip!
Post Reply