我正在处理 arcgis 地图,我正在尝试通过在我的 mapview 上调用 goTo() 来更新地图中心,但由于某种原因,地图只是变为空白并且永远不会更新,我正在记录新坐标并且它们是正确的.
我在这里使用参考文档:https ://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html
有一些arcgis经验的人可以帮助我。我知道这不是我的代码的问题,但它可能是 vue 和组件渲染的问题,因为它与 arcgis 相关
到目前为止,我已经尝试过 - 摆脱道具并在本地更新组件中的所有内容 - 使用键强制重新渲染组件
作为一个有趣的说明,如果我只是为我的新位置输入一些幻数,地图会正确更新,但是当我使用一些函数来获取位置然后将其传递时,它不起作用并且只显示为空白地图
我的应用程序.vue
<template>
<div id="app">
<web-map v-bind:centerX="lat" v-bind:centerY="long" ref="map"/>
<div class="center">
<b-button class="btn-block" @click="updateCenter()" variant="primary">My Location</b-button>
</div>
</div>
</template>
<script>
import WebMap from './components/webmap.vue';
export default {
name: 'App',
components: { WebMap },
data(){
return{
lat: null,
long: null,
}
},
methods:{
updateCenter(){
this.$refs.map.getLocation()
}
},
};
</script>
我的地图组件
<template>
<div></div>
</template>
<script>
import { loadModules } from 'esri-loader';
export default {
name: 'web-map',
data: function(){
return{
X: -118,
Y: 34,
}
},
mounted() {
console.log('new data',this.X,this.Y)
// lazy load the required ArcGIS API for JavaScript modules and CSS
loadModules(['esri/Map', 'esri/views/MapView'], { css: true })
.then(([ArcGISMap, MapView]) => {
const map = new ArcGISMap({
basemap: 'topo-vector'
});
this.view = new MapView({
container: this.$el,
map: map,
center: [-118,34], ///USE PROPS HERE FOR NEW CENTER
zoom: 8
});
});
},
beforeDestroy() {
if (this.view) {
// destroy the map view
this.view.container = null;
}
},
methods:{
showPos(pos){
console.log('new location',pos.coords.latitude,pos.coords.longitude)
this.view.goTo({center:[pos.coords.latitude,pos.coords.longitude]})
},
杨__羊羊
12345678_0001
HUWWW
随时随地看视频慕课网APP
相关分类