【ArcGIS API】Vue3+Vite+ArcGIS API for JavaScript——加载二维地图为例

ArcGIS API for JavaScript系列文章汇总:【ArcGIS API】汇总篇-CSDN博客

效果

具体实现

安装arcgis包

npm install @arcgis/core

将项目目录中node_modules\@arcgis\core\assets的文件复制到public/asstes中 

main.js中全局引入css样式

import '@arcgis/core/assets/esri/themes/dark/main.css';

 组件中编写

<template>
  <div id="viewDiv" class="viewDiv"></div>
</template>

<script setup>
import { onMounted } from 'vue'
import Map from '@arcgis/core/Map'
import MapView from '@arcgis/core/views/MapView'

onMounted(() => {
  const map = new Map({
    basemap: 'streets', //其他基础地图:satellite, hybrid, topo, gray, dark-gray, oceans, osm, national-geographic
  })
  console.log(map)
  const mapView = new MapView({
    container: 'viewDiv', // Reference to the scene div created in step 5
    map: map, // Reference to the map object created before the scene
    zoom: 4, // Sets zoom level based on level of detail (LOD)
    center: [15, 65], // Sets center point of view using longitude,latitude
  })
})
</script>

<style scoped>
.viewDiv {
  height: 100vh;
  width: 100vw;
}
</style>
  • 8
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值