write sth. upfront
Recently changed a job, the company is doing gis related services, before no contact with gis, just to show the map to the page is a lot of effort. So I'm going to put myself in the project to use the relevant technical points recorded for their own future look. Please leave your comments if you have written something bad.
Installing ArcGis in vue
Using arcgis in vue requires a file calledesri-loaderthing to load the arcgis file for us.
- First the npm install
npm install esri-loader -S
The relevant documentation on npm is referenced:/package/esri-loader
- After installation, import
import esriLoader from 'esri-loader'
The style file can be introduced in or in the current component, I chose to introduce it in the
import '../public/src/assets/js/4.10/esri/themes/light/'// Just use a relative path here!
utilization
The final load will be able to use the arcgis api, part of the code is as follows
const options = { url: "/src/assets/js/4.10/"// Be careful here, use absolute paths, this is the address hosted on the local server } esriLoader // Load modules on demand .loadModules([ "esri/Map", "esri/views/MapView",//2d view module "esri/views/SceneView",//3d view module ],options) .then(([ Map, MapView, SceneView ])=>{ (Map) })
If the console can print out the Map object, then we have successfully loaded arcgis in vue
Above is the ArcGis API for js in the use of sample details, more information about the ArcGis API please pay attention to my other related articles!