question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Interacting with the Marker component

See original GitHub issue

First of all, thanks for the great plugin! Please excuse me if this is a Vue.js question rather than specific to this plugin. I’m new to Vue.js and might just be missing something…

I have a map with many markers on it, and would like to react to the user clicking or hovering over one of the markers. I used v-on:l-mouserover and v-on:l-click to get an event out of it. The problem is that I can’t then access the marker component with its props, only the Leaflet object as target. I would like to be able to access the props as they tell me the identity of the marker in question. I tried using a mixin with the v-marker component to be able to use this, but I didn’t manage to do that.

I also tried to create a custom component for the marker, that includes the <v-marker> component within its template, but no marker was rendered. Should this be possible? (i.e. a custom component for the marker that adds the features I need and include it within a <v-map> component?)

Is there a better way?

Thanks for any help you can give!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
mgiraldocommented, May 16, 2019

i ended up adding a ref to each marker and using a shared identifier to open it programmatically like so:

this.$refs[identifier][0].mapObject.openPopup()

note the [0] because markers are in a v-for and the $refs returns an array there

1reaction
KoRiGaNcommented, Oct 5, 2017

Hi @omrihar,

Here is an example of how I would do it.

No modification of Vue2Leaflet required. Just send you contact as a parameter of the event handler.

Hope this helps!

Mickaël

Read more comments on GitHub >

github_iconTop Results From Across the Web

Adding a Map and Markers to a React Application
This tutorial shows you how to add a Map and Marker to a React ... The marker component uses similar patterns as the...
Read more >
Building A Custom Google Maps Marker ... - Daw-Chih Liou
We'll be building a proof of concept to create customer markers using any React component. Full user interaction with custom Marker. Let's go....
Read more >
Building a Custom Google Maps Marker ... - Better Programming
We'll learn how to build a custom Google Maps marker using any React component. We'll learn how to create animation and user interaction...
Read more >
Markers - Help Center - PandaSuite
Note: markers do not affect “normal” interactions on your component. If no action has been created on your markers, users will still be...
Read more >
Map with markers - Bravo Studio Help Center
Show a place or a list of places in a map as markers, and bind those markers to a detail page! · You'll...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found