首页 / 浏览问题 / 云GIS / 问题详情
iclient for leaflet无法显示地图
8EXP 2022年08月11日
iclient for leaflet无法显示地图,报错信息为Cannot read properties of undefined (reading 'tiledMapLayer')

1个回答

您好!

出现此种报错的可能性较多,包括未定义花括号中的某些属性,或是由于异步加载而未获取到属性等原因。

建议您附上完整代码,方便我们帮您排查错误。

希望可以帮助到您!
485EXP 2022年08月11日
<template>
  <div id="map"></div>
</template>

<script>
import L from 'leaflet'
export default {
  name: 'mapView',
  mounted () {
    this.initMap()
  },
  methods: {
    initMap () {
      const url = 'http://localhost:8090/iserver/services/map-data-LCtrack/rest/maps/WK_LINE%40track.leaflet'
      const map = L.map('map', {
        crs: L.CRS.EPSG4326,
        center: [0, 0],
        maxZoom: 18,
        zoom: 1
      })
      L.supermap.tiledMapLayer(url).addTo(map)
    }
  }
}
</script>

<style scoped>
  #map {
    margin: 0;
    overflow: hidden;
    background: #fff;
    width: 100%;
    height:100%;
    position: absolute;
  }
</style>

您好,请参考iClient for Leaflet指南中的模块化开发对相应模块进行引入。此外,您还需要留意一下您的url地址是否为地图服务的地址,而非在iServer中通过leaflet浏览的地址。

...