Acces to child property/methods
See original GitHub issueHello,
I’m trying out Vuejs these days. I’m not a font-dev expert though …
Here is my question :
I’m working on a project with an API serving geo_shapes through json format. I have all my polygons displayed.
In order to understand the underlying mechanism, I’m wondering how to proceed to change the polygon fillColor on mousever for highlighting. What is the recomended way to make this done and how can I access the setFillColor
in my Vue component ?
Here is chunks of component code :
<template>
<v-map id="leaflet">
<v-tilelayer></v-tilelayer>
<v-polygon v-for="area in areas" :key="area.id"
:lat-lngs="area.geometry.coordinates"
@l-dblclick="goto_sublevel(area)"
@l-mouseover="change_color()"> <!--???-->
<v-popup :content="area.name"></v-popup>
</v-polygon>
<v-polygon v-for="area in parent_area" :key="area.id"
:lat-lngs="area.geometry.coordinates" :color="'#ff6056'"></v-polygon>
</v-map>
</template>
<script>
import Vue2Leaflet from 'vue2-leaflet';
export default {
components: {
'v-map': Vue2Leaflet.Map,
'v-tilelayer': Vue2Leaflet.TileLayer,
'v-polygon': Vue2Leaflet.Polygon,
'v-popup': Vue2Leaflet.Popup
},
methods : {
goto_sublevel: function (level) {
// do something to retrieve data of next geographical level ...
},
change_color: function (?) {
// ??? is it here that magic should happen ?
},
}
</script>
Anyway, I found your api clear enough to had some fun with leaflet. Thanks for your job ! 😉
Dithyrambe
Issue Analytics
- State:
- Created 6 years ago
- Comments:14
Top Results From Across the Web
Access child property from parent scope - php - Stack Overflow
Take a look at an article about visibility. Basically, you cannot access parent's private properties/methods nor can the parent access its child's.
Read more >How to Access Child-class Methods from Parent-class in Python
You can access child methods from the parent. The example shows a real-time scenario, and it's helpful for interviews.
Read more >How to access child component properties in Vue.js 3
Useful tip to access methods and functions from child components ... Some of the Vuejs component properties we can access include functions, ...
Read more >Accessing child properties from parent classes / abstract ...
MATLAB defines a protected property to mean accessible from the class defining the property and all child classes (but NOT any parent classes)....
Read more >Is it possible to access child class with parent reference? - Quora
yes it is possible to hold child object with parent reference.. it is also a polymorphism and we generally use this approach when...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Nice !
Thanks all for your perfect explications ! I’ll go for the
setStyle
method. Looks cleaner to me. However, all insights were welcome. –> issue solved 😄And thx again for all the hard work on vue2-leaflet !
Dithyrambe
Hi @dithyrambe,
In vue2-leaflet you can set fillColor / opacity / weight etc the way 3RedM0 explained and this is the “more vue2-leaflet” approach: using reactivity of vue with leaflet.
If you want to access vue2-leaflet object and methods instead of using the property you can see this example. If you want to access leaflet object and methods instead you can see this example.
Let me know if these examples solved your issue.
Cheers,
Mickaël