<em>Mac</em>Book项目 2009年学校开始实施<em>Mac</em>Book项目,所有师生配备一本<em>Mac</em>Book,并同步更新了校园无线网络。学校每周进行电脑技术更新,每月发送技术支持资料,极大改变了教学及学习方式。因此2011
2021-06-01 09:32:01
Vue 2
ArcGIS JavaScript 4.22
注意 ArcGIS JavaScript3.x 和ArcGIS JavaScript 4.x框架差異較大
可以使用vue ui建立專案
package.json
"dependencies": { "core-js": "^3.8.3", "vue": "^2.6.14", "@arcgis/core":"4.22.2", "ncp":"^2.0.0" }, "devDependencies": { "@babel/core": "^7.12.16", "@babel/eslint-parser": "^7.12.16", "@vue/cli-plugin-babel": "~5.0.0", "@vue/cli-plugin-eslint": "~5.0.0", "@vue/cli-service": "~5.0.0", "eslint": "^6.8.0", "eslint-plugin-vue": "^5.2.3", "vue-template-compiler": "^2.6.14" },
ncp: 主要用於拷貝資源資訊
@arcgis/core 是arcgis_js倉庫
package.json中設定copy命令
"scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build", "lint": "vue-cli-service lint", "copy": "ncp ./node_modules/@arcgis/core/assets ./public/assets" },
安裝完依賴後執行 copy命令
yarn yarn copy yarn serve ------------------- npm i npm run copy npm run serve
執行完copy命令後,會將arcgis相關資源拷貝到public/assets目錄下
全域性引入
main.js
import '@arcgis/core/assets/esri/themes/light/main.css' import esriConfig from '@arcgis/core/config.js' esriConfig.assetsPath = './assets'
helloworld.vue
<template> <div class="hello"> <div id="map" class="map" v-show="flag == 'map'"> </div> <div id="earth" class="map" v-show="flag == 'earth'"></div> </div> </template> <script> import Map from '@arcgis/core/Map' import MapView from '@arcgis/core/views/MapView' import MapImageLayer from '@arcgis/core/layers/MapImageLayer' import ElevationLayer from '@arcgis/core/layers/ElevationLayer' import BaseElevationLayer from '@arcgis/core/layers/BaseElevationLayer' import SpatialReference from '@arcgis/core/geometry/SpatialReference' import SceneView from '@arcgis/core/views/SceneView' import Basemap from '@arcgis/core/Basemap' import TileLayer from '@arcgis/core/layers/TileLayer' export default { name: 'HelloWorld', data() { return { mapView: null, map: null, map3d: null, flag: 'earth' } }, mounted() { this.initBasemap() }, methods: { initBasemap() { const self = this //二維 const mapImageLayer = new MapImageLayer({ url: "http://192.168.3.156:6080/arcgis/rest/services/xiangyang/jichang/MapServer" }) this.map = new Map({ // basemap: basemap, layers: [mapImageLayer] }) this.mapView = new MapView({ container: 'map', map: self.map, spatialReference: new SpatialReference({ wkid: 3857 }), rotation: 41.2, zoom: 3 }) // 三維地形 const ExaggeratedElevationLayer = BaseElevationLayer.createSubclass({ properties: { exaggeration: 10 }, load: function () { // TopoBathy3D contains elevation values for both land and ocean ground this._elevation = new ElevationLayer({ url: "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/TopoBathy3D/ImageServer" }); this.addResolvingPromise( this._elevation.load().then(() => { this.tileInfo = this._elevation.tileInfo; this.spatialReference = this._elevation.spatialReference; this.fullExtent = this._elevation.fullExtent; }) ); return this; }, // Fetches the tile(s) visible in the view fetchTile: function (level, row, col, options) { // calls fetchTile() on the elevationlayer for the tiles // visible in the view return this._elevation.fetchTile(level, row, col, options).then( function (data) { const exaggeration = this.exaggeration; for (let i = 0; i < data.values.length; i++) { // Multiply the given pixel value // by the exaggeration value data.values[i] = data.values[i] * exaggeration; } return data; }.bind(this) ); } }); const basemap = new Basemap({ baseLayers: [ new TileLayer({ url: "https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer" }), new TileLayer({ url: "https://tiles.arcgis.com/tiles/nGt4QxSblgDfeJn9/arcgis/rest/services/terrain_with_heavy_bathymetry/MapServer" }), ] }); const elevationLayer = new ExaggeratedElevationLayer(); this.map3d = new Map({ basemap: basemap, ground: { layers: [elevationLayer] } }); const view = new SceneView({ container: "earth", map: this.map3d, alphaCompositingEnabled: true, qualityProfile: "high", camera: { position: [-55.039, 14.948, 19921223.3], heading: 2.03, tilt: 0.13 }, environment: { background: { type: "color", color: [255, 252, 244, 0] }, starsEnabled: true, atmosphereEnabled: true, lighting: { type: "virtual" } }, }); this.map3d.ground = { layers: [elevationLayer] }; } } } </script> <!-- Add "scoped" attribute to limit CSS to this component only --> <style scoped> .hello { width: 100%; height: 100%; } .map { width: 100%; height: 100%; } </style>
https://gitee.com/wolf_pro/vue_arcgis4.22.git
到此這篇關於Vue+ ArcGIS JavaScript APi的文章就介紹到這了,更多相關Vue+ ArcGIS JavaScript APi內容請搜尋it145.com以前的文章或繼續瀏覽下面的相關文章希望大家以後多多支援it145.com!
相關文章
<em>Mac</em>Book项目 2009年学校开始实施<em>Mac</em>Book项目,所有师生配备一本<em>Mac</em>Book,并同步更新了校园无线网络。学校每周进行电脑技术更新,每月发送技术支持资料,极大改变了教学及学习方式。因此2011
2021-06-01 09:32:01
综合看Anker超能充系列的性价比很高,并且与不仅和iPhone12/苹果<em>Mac</em>Book很配,而且适合多设备充电需求的日常使用或差旅场景,不管是安卓还是Switch同样也能用得上它,希望这次分享能给准备购入充电器的小伙伴们有所
2021-06-01 09:31:42
除了L4WUDU与吴亦凡已经多次共事,成为了明面上的厂牌成员,吴亦凡还曾带领20XXCLUB全队参加2020年的一场音乐节,这也是20XXCLUB首次全员合照,王嗣尧Turbo、陈彦希Regi、<em>Mac</em> Ova Seas、林渝植等人全部出场。然而让
2021-06-01 09:31:34
目前应用IPFS的机构:1 谷歌<em>浏览器</em>支持IPFS分布式协议 2 万维网 (历史档案博物馆)数据库 3 火狐<em>浏览器</em>支持 IPFS分布式协议 4 EOS 等数字货币数据存储 5 美国国会图书馆,历史资料永久保存在 IPFS 6 加
2021-06-01 09:31:24
开拓者的车机是兼容苹果和<em>安卓</em>,虽然我不怎么用,但确实兼顾了我家人的很多需求:副驾的门板还配有解锁开关,有的时候老婆开车,下车的时候偶尔会忘记解锁,我在副驾驶可以自己开门:第二排设计很好,不仅配置了一个很大的
2021-06-01 09:30:48
不仅是<em>安卓</em>手机,苹果手机的降价力度也是前所未有了,iPhone12也“跳水价”了,发布价是6799元,如今已经跌至5308元,降价幅度超过1400元,最新定价确认了。iPhone12是苹果首款5G手机,同时也是全球首款5nm芯片的智能机,它
2021-06-01 09:30:45