Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Has anyone successfully used mil-sym-js in an Angular project? #39

Open
Zaandar opened this issue Jan 22, 2021 · 5 comments
Open

Has anyone successfully used mil-sym-js in an Angular project? #39

Zaandar opened this issue Jan 22, 2021 · 5 comments

Comments

@Zaandar
Copy link

Zaandar commented Jan 22, 2021

I am trying to use mil-sym-js in an Angular project but am having no luck importing and using the functions. I followed the instructions on the documentation and also tried the Angular way to do it with no luck. Any pointers?

@ComBatVision
Copy link

Yes. I have used it.

Add following into index.html

  <script type="text/javascript" src="assets/mil-sym/sm-bc.js"></script>
  <link rel="stylesheet" href="assets/mil-sym/renderer.css" type="text/css" charset="utf-8" />
  <link rel="stylesheet" href="assets/mil-sym/fonts/SinglePoint.ttf" type="text/css"/>
  <link rel="stylesheet" href="assets/mil-sym/fonts/SinglePoint.woff" type="text/css"/>
  <link rel="stylesheet" href="assets/mil-sym/fonts/SinglePoint.woff2" type="text/css"/>

Then import variable:
declare var armyc2: any;
declare var java: any;

Then declare constants like:
static readonly RendererUtilities = armyc2.c2sd.renderer.utilities.RendererUtilities;
static readonly RendererSettings = armyc2.c2sd.renderer.utilities.RendererSettings;
static readonly SymbolUtilities = armyc2.c2sd.renderer.utilities.SymbolUtilities;
static readonly SymbolDefTable = armyc2.c2sd.renderer.utilities.SymbolDefTable;
static readonly UnitDefTable = armyc2.c2sd.renderer.utilities.UnitDefTable;
static readonly ModifiersTG = armyc2.c2sd.renderer.utilities.ModifiersTG;
static readonly ModifiersUnits = armyc2.c2sd.renderer.utilities.ModifiersUnits;
static readonly MilStdAttributes = armyc2.c2sd.renderer.utilities.MilStdAttributes;

And then use them.

@Zaandar
Copy link
Author

Zaandar commented Jan 26, 2021

Great! Thanks!

@Zaandar Zaandar closed this as completed Jan 27, 2021
@Zaandar Zaandar reopened this Jan 27, 2021
@Zaandar
Copy link
Author

Zaandar commented Jan 27, 2021

@ComBatVision Just curious, what are you using for maps? I am using Cesium.

@ComBatVision
Copy link

@Zaandar I am using NASA WorldWind

@chusitoo
Copy link

chusitoo commented Jan 20, 2022

I found this very helpful for a start. I did end up taking a slightly different approach, though.

angular.json

"styles": [
    "src/assets/mil-sym-js/renderer.css"
],
"scripts": [
    "src/assets/mil-sym-js/sm-bc.js"
],

app.component.ts

declare var armyc2: any;
declare var java: any;

export const RendererUtilities = armyc2.c2sd.renderer.utilities.RendererUtilities;
export const RendererSettings = armyc2.c2sd.renderer.utilities.RendererSettings;
export const SymbolUtilities = armyc2.c2sd.renderer.utilities.SymbolUtilities;
export const SymbolDefTable = armyc2.c2sd.renderer.utilities.SymbolDefTable;
export const UnitDefTable = armyc2.c2sd.renderer.utilities.UnitDefTable;
export const ModifiersTG = armyc2.c2sd.renderer.utilities.ModifiersTG;
export const ModifiersUnits = armyc2.c2sd.renderer.utilities.ModifiersUnits;
export const MilStdAttributes = armyc2.c2sd.renderer.utilities.MilStdAttributes;

calling_script.ts

import { RendererSettings, ModifiersUnits } from 'src/app/app.component';

// Set some properties
RendererSettings.setUseCesium2DScaleModifiers(true);
RendererSettings.setSymbologyStandard(RendererSettings.Symbology_2525C);
RendererSettings.setDefaultPixelSize(42);

It would also appear that the fonts, which are referenced in renderer.css, are automatically imported with this approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants