1 下载vue-cli
npm install -g @vue/cli
2. 下载成功之后 创建项目
vue create my-project
3. cd my-project 下载gis模块
npm install --save esri-loader
4. 添加如下代码 运行即可查看地图
<template>
<div style="height:600px;">
</div>
</template>
<script>
import { loadModules } from 'esri-loader';
export default {
name: '',
mounted() {
loadModules(['esri/Map', 'esri/views/MapView'], { css: true })
.then(([ArcGISMap, MapView]) => {
const map = new ArcGISMap({
basemap: 'topo-vector'
});
this.view = new MapView({
container: this.$el,
map: map,
center: [-118, 34],
zoom: 8
});
});
},
beforeDestroy() {
if (this.view) {
this.view.container = null;
}
}
};
</script>
<style scoped>
div {
padding: 0;
margin: 0;
width: 100%;
height: 100%;
}
</style>