我正在使用ArcGIS JSAPI 4.12,并希望使用空间幻觉在地图上绘制军事符号。
当我添加milsymbol.js到脚本时,控制台返回错误Uncaught SyntaxError: Cannot use import statement outside a module,因此我添加type="module"到脚本时,它返回Uncaught ReferenceError: ms is not defined。
这是我的代码:
<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 …Run Code Online (Sandbox Code Playgroud) 过去,app-module-path每当我想在 Node.js 应用程序中使用相对路径时,我都会使用它。如果我通过该格式使用 ES 模块.mjs,如何在某个目录路径变为相对路径的情况下具有相同的功能?
以另一种方式,我是否能够为目录分配一个别名,以便所有相对路径都相对于该别名,就像./路径的别名相对于当前目录一样。
我正在使用Node v10.11.0,并且正在从Ubuntu 18.04运行此脚本。
我的文件设置如下所示:
main.js
import Login from './Login.mjs';
class Main {
constructor() {
const login = new Login();
login.login();
}
}
new Main();
Run Code Online (Sandbox Code Playgroud)
Login.mjs
import readline from 'readline';
class Login {
constructor() {
this.username = '';
this.password = '';
this.readline = readline.createInterface({
input: process.stdin,
output: process.stdout
});
}
login() {
this.readline.question('What is your username?', answer => {
this.username = answer;
});
this.readline.question('What is your password?', answer => {
this.password = answer;
});
}
}
export default Login;
Run Code Online (Sandbox Code Playgroud)
我main.js …