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.

[help] component inside geojson

See original GitHub issue

Hi,

Let’s use the example geojson component.

Now, let’s say that I want, for each geometry to bind a popup. Easy, in options I put a onEachFeature and place a bindPopup

options: {
  onEachFeature (f. l) {
    l.bindPopup(f.properties.nom)
 }
}

Now is the tricky part : how can I add a component to this popup and even better, a router-link ? It really look like a dynamic component injection… It seems that this is not the right way to do things in vue.js (https://forum-archive.vuejs.org/topic/349/injecting-components-to-the-dom/2) but I can’t figure out how to do it.

In advance thanks

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
KoRiGaNcommented, Nov 14, 2017

Hi @RemiDesgrange,

You can find a working example of this in examples/src/components/GeoJSON2.vue.

I’m closing this issue for now. If you still have trouble with this please reopen it.

Mickaël

1reaction
AchilleAshcommented, Sep 6, 2017

Hi @RemiDesgrange ,

I use dynamic component mounting to dynamically add a Leaflet Control on my map depending on the fixture. It looks like:


  L.Control.TopRight = L.Control.extend({
    onAdd: (map) => {
      const vm = new topRightComponent({propsData: {}}).$mount();
      return vm.$el;
    },
  });

the bindPopup method can receive an html element as argument, so using bindPopup(vm.$el) should do the trick.

Timothé

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating a Single GeoJSON component with two separate ...
I want to create a single GeoJSON component in React using react-leaflet to display the information through color on the map.
Read more >
Canvas App Map component with GeoJSON
I'm working on a Canvas App that uses the Map component combined with the Address Input component to locate an address on a...
Read more >
GeoJSON specification
GeoJSON is a geospatial data interchange format based on JavaScript Object Notation (JSON). It defines several types of JSON objects and the manner...
Read more >
React Leaflet Tutorial using GeoJSON to Create a Map
React leaflet allows react developers to use components to build a leaflet map. We will be using the Map component, GeoJSON component to ......
Read more >
Chapter 7 GeoJSON | Introduction to Web Mapping
In this chapter, we are going to learn about GeoJSON—a plain text format for vector layers. On the one hand, GeoJSON is a...
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