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:

    <template>
    </template> <script> ...... </script> <style scoped> @import './main.css'; </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...

相关推荐
艾莉丝努力练剑13 分钟前
深入详解编译与链接:翻译环境和运行环境,翻译环境:预编译+编译+汇编+链接,运行环境
c语言·开发语言·汇编·学习
汪子熙1 小时前
Angular i18n 资源加载利器解析: i18n-http-backend
前端·javascript·面试
天天扭码1 小时前
前端必备 | 一文掌握React的Token管理
前端·javascript·react.js
烛阴1 小时前
用Joi守住数据防线!Node.js/前端必备校验神器入门与进阶
前端·javascript
开发者工具分享2 小时前
Lua 的速度为什么比 Python 快
开发语言·python·lua
蔗理苦2 小时前
2025-05-28 Python&深度学习8——优化器
开发语言·pytorch·python·深度学习·优化器
格子衫-20032 小时前
Java八股-Java优缺点,跨平台,jdk、jre、jvm关系,解释和编译
java·开发语言·jvm
Yurko133 小时前
【C语言】函数指针及其应用
c语言·开发语言·学习
zhifanxu3 小时前
Android开发常用Kotlin高级语法
android·开发语言·kotlin
困惑阿三3 小时前
解决 iTerm2 中 nvm 不生效的问题(Mac 环境)
开发语言·前端·macos·bash