Javascript 如何防止moveend锁定api调用导致的映射

Javascript 如何防止moveend锁定api调用导致的映射,javascript,leaflet,vuejs2,Javascript,Leaflet,Vuejs2,我有一张地图,它只根据地图当前坐标显示标记,我们通过外部API获得标记位置 moveEnd (e) { // console.log(e.target) const map = this.$refs.map.mapObject const bound = map.getBounds() const minx = bound.getWest() const maxx = bound.getEast() const miny = boun

我有一张地图,它只根据地图当前坐标显示标记,我们通过外部API获得标记位置

  moveEnd (e) {
        // console.log(e.target)

    const map = this.$refs.map.mapObject
    const bound = map.getBounds()
    const minx = bound.getWest()
    const maxx = bound.getEast()
    const miny = bound.getSouth()
    const maxy = bound.getNorth()
    const zoom = map.getZoom()
    let cat = 2
    console.log(zoom)
    if (zoom <= 2) cat = 1
    else if (zoom >= 4) cat = 3

    const queryString = `?maxx=${maxx}&minx=${minx}&maxy=${maxy}&miny=${miny}&cat=${cat}`

 this.fetchPortsOnMap(queryString)
  }

你能发布你的fetchPortsOnMap函数吗?@AlexParij我已经添加了我的函数,loadingFunc只是一个标志,我用来防止函数在仍在抓取时再次被调用。为什么你认为映射正在等待函数响应。看起来像是常规异步呼叫我。我看到它可以冻结映射的唯一地方是从响应``this.ports=response.data``加载新数据时,因为映射在响应挂起时冻结,在收到响应时解冻,所以我决定通过使api调用只发生一次来测试我的理论,因为我认为可能是标记问题(一次显示不到300个标记),发现地图工作正常
  fetchPortsOnMap (queryString) {
        this.loadingFunc = true
        httpAuth().get('ports' + queryString)
          .then((response) => {
            this.loadingFunc = false
            this.ports = response.data
          })
      },