SEITS-GIS / GISViewer-Vue

3 stars 4 forks source link

切换路由后地图就不渲染了 #3

Open superfeng-99 opened 4 years ago

superfeng-99 commented 4 years ago
`<div id="container" v-if="hackReset" style="width:100%; height:100%">
  <gis-viewer
    ref="gisViewer"
    platform="gd"
    :map-config="mapConfig"
    @map-loaded="mapLoaded"
    @marker-click="showGisDeviceInfo"
  />
</div>`

封装了单独的组件。在两个页面调用,切换路由后,地图就消失了。需要刷新页面一次地图才会出现。

`

` 地图消失后html就只剩下这些。

GISerGll commented 4 years ago

问题可能出现在MapAppArcgis2D.ts initialize方法: baseLayers.addMany( mapConfig.baseLayers.map((layerConfig: ILayerConfig) => { if (layerConfig.type === 'tiled') { delete layerConfig.type; let tileLayer = new TileLayer(layerConfig) // return new TileLayer(layerConfig); 把layerConfig.type = "tiled"再加回去 layerConfig.type = "tiled"; return tileLayer; } else if (layerConfig.type === 'webtiled') { return new WebTileLayer({ urlTemplate: layerConfig.url, subDomains: layerConfig.subDomains || undefined }); } })