smeijer / leaflet-geosearch

A geocoding/address-lookup library supporting various api providers.
https://smeijer.github.io/leaflet-geosearch/
MIT License
1.02k stars 271 forks source link

Can't make more than 1 search with vue-geosearch #291

Closed SolimanGit closed 2 years ago

SolimanGit commented 2 years ago

Hi ! I have a weird error : TypeError: Cannot create property '_leaflet_id' on string '182'. It works perfectly for the 1st search but when I'm trying to search an second address, in the bar it's perfect, but when I press enter it doesn't do anything. I'm using a vue component to use the geosearch and this might be the problem but I can't see why. Thank you in advance.

vue_geosearch from fega -> LINK


  <div></div>
</template>

<script>
// import L from 'leaflet';
import { GeoSearchControl } from 'leaflet-geosearch';
export default {
  props: {
    options: {
      required: true
    }
  },
  name: 'v-geosearch',
  mounted() {
    this.add();
  },
  beforeDestroy() {
    this.remove();
  },
  methods: {
    deferredMountedTo(parent) {
      const searchControl = new GeoSearchControl(this.options);
      parent.addControl(searchControl);
      searchControl.getContainer().onclick = e => {
        e.stopPropagation();
      };
    },
    remove() {
      if (this.markerCluster) {
        this.$parent.removeLayer(this.markerCluster);
      }
    },
    add() {
      if (this.$parent._isMounted) {
        this.deferredMountedTo(this.$parent.mapObject);
      }
    }
  }
};```
smeijer commented 2 years ago

I don't support the vue plugin, but I do see that they use an old version of this library (3.1.0 while we are on 3.5.0). An upgrade might help.