第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

view.goTo 地圖呈現(xiàn)空白 arcgis

view.goTo 地圖呈現(xiàn)空白 arcgis

楊__羊羊 2022-07-08 09:56:30
我正在處理 arcgis 地圖,我正在嘗試通過在我的 mapview 上調(diào)用 goTo() 來更新地圖中心,但由于某種原因,地圖只是變?yōu)榭瞻撞⑶矣肋h(yuǎn)不會更新,我正在記錄新坐標(biāo)并且它們是正確的.我在這里使用參考文檔:https ://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html有一些arcgis經(jīng)驗的人可以幫助我。我知道這不是我的代碼的問題,但它可能是 vue 和組件渲染的問題,因為它與 arcgis 相關(guān)到目前為止,我已經(jīng)嘗試過 - 擺脫道具并在本地更新組件中的所有內(nèi)容 - 使用鍵強制重新渲染組件作為一個有趣的說明,如果我只是為我的新位置輸入一些幻數(shù),地圖會正確更新,但是當(dāng)我使用一些函數(shù)來獲取位置然后將其傳遞時,它不起作用并且只顯示為空白地圖我的應(yīng)用程序.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]})        },
查看完整描述

2 回答

?
12345678_0001

TA貢獻(xiàn)1802條經(jīng)驗 獲得超5個贊

轉(zhuǎn)變:


this.view = new MapView({

    container: this.$el,

    map: map,

    center: [-118,34],   ///USE PROPS HERE FOR NEW CENTER

    zoom: 8

  });


this.view = new MapView({

        container: this.$el,

        map: map });

this.view.center.longitude = -118;

this.view.center.latitude = 34;

this.view.zoom = 8;

Tao 的另一個答案在 .goTo({center: []}) 方法調(diào)用中具有向后的經(jīng)度/緯度,這就是它走向海洋的原因:https ://developers.arcgis.com/javascript/latest/api -reference/esri-views-MapView.html#goTo


查看完整回答
反對 回復(fù) 2022-07-08
?
HUWWW

TA貢獻(xiàn)1874條經(jīng)驗 獲得超12個贊

這是可行的:

https://codesandbox.io/s/frosty-glitter-39wpe?file=/src/App.vue

我是從頭開始制作的,只從您那里獲取了一小部分內(nèi)容,并將它們與 ArcGIS 中的一些示例(我根本不熟悉)結(jié)合起來。

需要注意的一件事是,它.goTo({center: [lat, long]})沒有按預(yù)期工作:它一直集中在某個海洋的中間。
然后我從導(dǎo)入 Pointesri并通過centeras new Point(long, lat),這似乎產(chǎn)生了預(yù)期的結(jié)果。由于它有效,我沒有進(jìn)一步研究,但我想如果沒有轉(zhuǎn)換它應(yīng)該是可行的。您可能需要傳入坐標(biāo)系或類似的東西。

據(jù)我所知,您的示例中有什么問題是您嘗試將數(shù)據(jù)從父級傳遞給子級的方式。您希望this.$refs.map成為 Vue 實例,但事實并非如此。它是一個 DOM 元素。它基本上是 Vue 實例的$el. 從父實例訪問子方法并不是那么簡單。另一件需要注意的事情是,即使您在示例中綁定centerXcenterYchild,但您似乎從未使用過它們(但我想這只是您嘗試使用 props 時的遺留問題!?)。

無論如何,在我的示例中,我選擇簡單地更新孩子的 coords 道具,同時使用watchfn 來處理重新居中。


查看完整回答
反對 回復(fù) 2022-07-08
  • 2 回答
  • 0 關(guān)注
  • 297 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號