milsymbol icon indicating copy to clipboard operation
milsymbol copied to clipboard

Hi, How can we change the color of direction arrow?

Open ajinra020307 opened this issue 3 years ago • 1 comments

ajinra020307 avatar Mar 19 '21 10:03 ajinra020307

It's not possible to directly change the colour of a single part within milsymbol because the draw instruction for it uses the colour specified for the rest of the symbol frame parts.

https://github.com/spatialillusions/milsymbol/blob/1c17e57282f505fb9ebcd42e04ef2ab1e1b102e6/src/symbolfunctions/directionarrow.js#L32

If you really need to change the colour of the direction arrow, you could instead create a custom symbol part instead. Essentially all you would have to do is copy the logic from src/symbolfunctions/directionarrow.js and then add the relevant options when creating your symbol:

Pseudo code example:


var custDirArrow = function (symbol, colour, dir) {
 // Implementation goes here...
}

ms.addSymbolPart(function () {
        var drawArray1 = []; 
        var drawArray2 = [];

       if (this.options.custDirArrowColor !== undefined && this.options.custDirArrowDir) {
           drawArray2.push(custDirArrow(this, this.options.custDirArrowColor, this.options.custDirArrowDir));
       }

        return {
            pre: drawArray1,
            post: drawArray2,
        };
})

var symb = new ms.Symbol("SFG*UCIZ--*****", {
    dtg: "30140000ZSEP97",
    location: "0900000.0E570306.0N",
    size: 35,
    custDirArrowColor:"#FF0000",
    custDirArrowDir:"290"
});

I have provided an example of a similar solution here https://github.com/spatialillusions/milsymbol/issues/249#issuecomment-931138101

Hope this helps

MattShawPhoto avatar Sep 30 '21 09:09 MattShawPhoto