ADD: added function for the dynamic creation of entities

This commit is contained in:
hwinkel
2023-09-07 22:49:49 +02:00
parent 658830bab6
commit b391c8e7ff
4 changed files with 124 additions and 45 deletions

View File

@@ -8,26 +8,68 @@ const iconShip = new Icon({
popupAnchor: [-25, -40],
});
const iconSize = {
"Team/Crew": 5,
"Squad": 10,
"Section": 15,
"Platoon/detachment": 20,
"Company/battery/troop": 25,
"Battalion/squadron": 30,
"Regiment/group": 35,
"Brigade": 40,
"Division": 45,
"Corps/MEF": 50,
"Army": 55,
"Army Group/front": 60,
"Region/Theater": 65,
"Command": 70
};
const HostileLetter = "H";
const FriendLetter = "F";
const NeutralLetter = "N";
const AirLetter = "A";
const SurfaceLetter = "S";
const SubsurfaceLetter = "U";
const Size = 25;
function createIcon(Type , Side )
{
var TypeLetter = "S";
var SideLetter = "N";
switch (Side) {
case "Hostile":
SideLetter = HostileLetter;
break;
case "Friend":
SideLetter = FriendLetter;
break;
case "Neutral":
SideLetter = NeutralLetter;
break;
default:
SideLetter = "N";
break;
}
switch (Type) {
case "Air":
TypeLetter = AirLetter;
break;
case "Surface":
TypeLetter = SurfaceLetter;
break;
case "Subsurface":
TypeLetter = SubsurfaceLetter;
break;
default:
SideLetter = "N";
break;
}
var IconS = new ms.Symbol(
"S"+SideLetter+TypeLetter+"*"+"--------"
)
IconS = IconS.setOptions({ size: 25 });
var Symbol = new Icon({
iconUrl: IconS.toDataURL(),
iconAnchor: [IconS.getAnchor().x, IconS.getAnchor().y],
})
return Symbol
}
var Friend = new ms.Symbol(
"SFP---------", {
uniqueDesignation: "Friend"
"SFS*--------", {
// uniqueDesignation: "Friend"
})
// Now that we have a symbol we can ask for the echelon and set the symbol size
Friend = Friend.setOptions({ size: 25 });
@@ -39,7 +81,7 @@ const friend = new Icon({
var hostile = new ms.Symbol(
"SHP---------", {
"SHU*---------", {
uniqueDesignation: "Hostile"
})
// Now that we have a symbol we can ask for the echelon and set the symbol size
@@ -50,4 +92,4 @@ const Hostile = new Icon({
iconAnchor: [hostile.getAnchor().x, hostile.getAnchor().y],
});
export { iconShip, friend,Hostile };
export { iconShip, friend,Hostile,createIcon };