Vue2leaflet: generate maker with click

Created on 23 Aug 2019  路  2Comments  路  Source: vue-leaflet/Vue2Leaflet

Good morning, I need to generate a maker when the person clicks on the map, obviously the maker has to be generated and give me the latitude and longitude, will this be possible? From already thank you very much

Most helpful comment

Take a look at this fiddle: http://jsfiddle.net/b2g1Lt9y/
The important bits are to:

  • have an <l-marker> tag with a v-for that points to an array of markers
  • have a @click (or v-on:click) event handler on your map that binds to a method in your component
  • this method (addMarker) has an event, which conveniently supplies the latlng of where the user clicked. So you only need to add this latlng to your array of markers

All 2 comments

Take a look at this fiddle: http://jsfiddle.net/b2g1Lt9y/
The important bits are to:

  • have an <l-marker> tag with a v-for that points to an array of markers
  • have a @click (or v-on:click) event handler on your map that binds to a method in your component
  • this method (addMarker) has an event, which conveniently supplies the latlng of where the user clicked. So you only need to add this latlng to your array of markers

Thank you, this worked for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

srtonz picture srtonz  路  4Comments

mpallante picture mpallante  路  4Comments

lufias picture lufias  路  3Comments

shtw picture shtw  路  5Comments

mnboos picture mnboos  路  3Comments