0

I defined addMarker and polylineClick functions. addMarker is called when clicking on the map and polylineClick is called when clicking on a polyline. But when I click on a polyline, map click event also occurs and addMarker function is called.

How can I disable map click event when I click on a polyline?

Here is the code:

  <l-map
    ref="map"
    style="z-index:1"
    :zoom="zoom"
    :center="center"
    :bounds="boundMarkers"
    @click="addMarker"
  >

(...)

<l-polyline
      v-for="(stop,index) in stops"
      v-if="index < stops.length -1 "
      :key="stop.id"
      :lat-lngs="[getLatLng(stops[index].lat,stops[index].long), getLatLng(stops[index+1].lat,stops[index+1].long)]"
      color="green"
      :fill-opacity="0.2"
      :weight="16"
      :opacity="0.5"
      @click="polylineClick($event,index)"
    />


(...)

methods: {
            polylineClick(e,index){
                console.log('polyline click')

            },

(...)

           addMarker(event, openDrawer=true, index=-1) {
            console.log('map click')
           }

I use Vue2-leaflet .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.