AnsweredAssumed Answered

Drawing Military Symbols on Map

Question asked by sjerrysss on Oct 2, 2019
Latest reply on May 22, 2020 by baba777

I'm using ArcGIS JSAPI 4.12 and wishing to use Spatial Illusions to draw military symbols on map.

When I add milsymbol.js to script, the console returns error Uncaught SyntaxError: Cannot use import statement outside a module, so I add type="module" to the script, the it returns Uncaught ReferenceError: ms is not defined.

Here's my code:

<link rel="stylesheet" href="https://js.arcgis.com/4.12/esri/css/main.css">
<script src="https://js.arcgis.com/4.12/">
</
script><script type="module" src="milsymbol-2.0.0/src/milsymbol.js"></script>

<script>
        require([
          "esri/Map",
          "esri/views/MapView",
          "esri/layers/MapImageLayer",
          "esri/layers/FeatureLayer"
        ], function (Map, MapView, MapImageLayer, FeatureLayer) {
             var symbol = new ms.Symbol("SFG-UCI----D", { size: 30 }).asCanvas(3);
            var map = new Map({
                basemap: "topo-vector"
            });            
            var view = new MapView({
                container: "viewDiv",
                map: map,
                center: [121, 23],
                zoom: 7
            });
        });
    </script>

So, whether I add type="module" or not, there's always errors. However, in the official document of Spatial Illusions, there's no type="module" in the script. I'm now really confused, how do they manage to get it work without adding the type?

milsymbol.js

import { ms } from "./ms.js";import Symbol from "./ms/symbol.js";ms.Symbol = Symbol;export { ms };

Outcomes