Course 1: Best Practice of RK‘s start Maps SDK for javascript

this blog article is for recording my experience for using maps sdk for javascript in vue with vite tools. I had make it before. But I didn't record it.So I forget. Now I need use it again. This time I will remember all the steps here for the next time using.

environment

  1. vite: https://vite.dev/guide/
  2. vue:
  3. maps sdk for js: https://developers.arcgis.com/javascript/latest/get-started-npm/

1. first of all, download template and run it.

reference here : https://github.com/Esri/jsapi-resources/tree/main/core-samples/jsapi-vue

if you run npm create vite.Then I will laugh at you, because you re a DASHABI!! Why? If you read the official document you will find there are workable samples with "maps sdk with vue and vite". Dont create tyres OK!

see here for more information: https://github.com/Esri/jsapi-resources/tree/main/core-samples/jsapi-vue

now you downloaded the samples and renamed:

dont worry, open in the vscode. Before, make sure you have installed NVM in your computer. And now use nvm install node and npm.In my example, I installed node of version :

I am not sure whether other versions could make error during runtime.

OK, then you open vscode and run :

复制代码
npm install pnpm -g

yes, we use pnpm instead of npm. I like pnpm more.

then run the command:

复制代码
pnpm install
pnpm run dev

now let's have a look on directories and code:

I must admire: there is nothing but few codes.

2. What is in the templates

  • package.json

    "dependencies": {
    "@arcgis/core": "~4.32.0",
    "vue": "^3.5.13"
    },
    "devDependencies": {
    "@vitejs/plugin-vue": "^5.2.1",
    "vite": "^6.1.1"
    }

as we see, only @arcgis/core and vue here,it's clean.

  • index.html

    here are two important things we need remember:
    first is:

and another is :

复制代码
<script type="module" src="/src/main.js"></script>
  • main.js

    we can see the app div in the index.html have bind here.And bind App.vue on the index.html.
    And more detail we can reference here:
  • At last, most important of all, how to load arcgis related module?
  1. include dependency in package.json:"@arcgis/core": "~4.32.0"

  2. import arcgis css in main.css: @import "https://js.arcgis.com/4.32/@arcgis/core/assets/esri/themes/light/main.css";

  3. import main.css in App.vue's style:

Congraduations !!! You have known how to start maps sdk with vue and vite.You're a 合格的giser了!

In the next course, I will introduce what are different between mapview, scenview... And differences between featureServer, mapServer...

相关推荐
এ慕ོ冬℘゜12 小时前
使用 jQuery 动态渲染表格与状态切换
前端·javascript·jquery
Littlehero_12112 小时前
QT自定义控件之热换站系统(源码开源)
开发语言·qt
meilindehuzi_a12 小时前
Python 基础语法(1):常量、变量、类型、输入输出与运算符
开发语言·python
caimouse12 小时前
ReactOS 窗口系统分析(5):可见区域与窗口 DC — vis.c + windc.c
c语言·开发语言
OPEN-F12 小时前
Python进阶教程:装饰器与生成器深入
开发语言·python
智购科技自动售货机厂家13 小时前
2026自动售货机AI视觉识别优化:从YOLOv11n模型量化到RKNN部署的端侧推理工程实践~YH
javascript·人工智能·yolo·机器学习·计算机视觉·目标跟踪·perl
晓说前端13 小时前
TypeScript 核心语法应用 —— Vue 3 中的使用(下)
前端·javascript·typescript·类型系统
千里码aicood14 小时前
基于Python的电商数据采集系统(大数据+爬虫)
开发语言·python
福大大架构师每日一题14 小时前
ragflow v0.27.0 发布:Go 后端全面对齐、智能体搜索与知识编译大升级,超全更新解析
开发语言·后端·golang
陈皮波比茶14 小时前
Python项目实战-网络机器人(爬虫)
开发语言·网络·爬虫·python·机器人