Closed DanRamage closed 4 years ago
As usual, after I posted my question I figured it out. I was overthinking things. Anyway it's as simple as putting the component in.
<vl-interaction-select :features.sync="selectedFeatures" :layers="['sites']">
<vl-overlay v-for="feature in selectedFeatures"
:key="feature.id"
:id="feature.id"
:position="feature.geometry.coordinates"
:auto-pan="true"
:auto-pan-animation="{ duration: 300 }">
<div style="background: grey">
<WQPopup :feature="feature"></WQPopup>
</div>
</vl-overlay>
Just take a note that if you are already synchronizing selected features into your data property, then you don't. need to add vl-overlay
cmp as a child of vl-interaction-select
.
This will have a same result
<vl-interaction-select :features.sync="selectedFeatures" :layers="['sites']">
</vl-interaction-select>
<vl-overlay v-for="feature in selectedFeatures"
:key="feature.id"
:id="feature.id"
:position="feature.geometry.coordinates"
:auto-pan="true"
:auto-pan-animation="{ duration: 300 }">
<div style="background: grey">
<WQPopup :feature="feature"></WQPopup>
</div>
</vl-overlay>
Or with vl-overlay
as child inside vl-interaction-select
scoped slot this ca be
<vl-interaction-select :layers="['sites']">
<template slot-scope="selection">
<vl-overlay v-for="feature in selection.features"
:key="feature.id"
:id="feature.id"
:position="feature.geometry.coordinates"
:auto-pan="true"
:auto-pan-animation="{ duration: 300 }">
<div style="background: grey">
<WQPopup :feature="feature"></WQPopup>
</div>
</vl-overlay>
</template>
</vl-interaction-select>
I've been looking at the demo but I am having trouble understanding the overlays and interactions. Here's my template:
I am just not grasping the vl-overlay functionality. Based on the type of feature that is clicked on, I want to have conditional logic to determine which of my custom vue components to use as the popup. I'm sure most of my issues stem from not being well versed in Vue. My map is populated correctly from the GeoJSON REST and the vl-interaction-select does select the point I click on. I also get the simple vl-overlay I have above, however there is no style, it is just text on the map.
Is it possible to A) use custom Vue component as a popup and B) dynamically determine which component to use?
Thanks for any help!