Удалить слой наложения изображения в Leaflet - PullRequest
0 голосов
/ 03 мая 2020

Я пытаюсь разместить эскиз на здании на карте с помощью Leaflet. Мне это тоже удалось, я могу разместить и масштабировать изображение в формате SVG на карте. Но когда я добавляю новый эскиз на карту, я хочу, чтобы старый эскиз был удален с карты.

    map.removeLayer(sketchLayer)
    sketchLayer.removeFrom(map)
    map.removeLayer(L.sketchLayer)

Я попробовал эти

Мои коды,

 splitCoordinate (value) {
      const topLeftCoordinates = value.top_left.split(',')
      const topRightCoordinates = value.top_right.split(',')
      const bottomLeftCoordinates = value.bottom_left.split(',')
      this.initMap(topLeftCoordinates, topRightCoordinates, bottomLeftCoordinates)
    },
    initMap (topLeftCoordinates, topRightCoordinates, bottomLeftCoordinates) {
      let map = this.$refs.map.mapObject
      map.flyTo(new L.LatLng(topLeftCoordinates[0], topLeftCoordinates[1]), 20, { animation: true })
      const vm = this
      var topleft = L.latLng(topLeftCoordinates[0], topLeftCoordinates[1])
      var topright = L.latLng(topRightCoordinates[0], topRightCoordinates[1])
      var bottomleft = L.latLng(bottomLeftCoordinates[0], bottomLeftCoordinates[1])
      var sketchLayer = L.imageOverlay.rotated(vm.imgUrl, topleft, topright, bottomleft, {
        opacity: 1,
        interactive: true
      })
      map.addLayer(sketchLayer)
    }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...