The function addLayer
is not included in the public API for the l-map
component. Even if it were, the 'layer' parameter passed to addLayer
should be the Vue2Leaflet wrapper component, not the actual Leaflet layer.
To understand this better, take a look at the code in LFeatureGroup.vue
:
https://github.com/KoRiGaN/Vue2Leaflet/blob/940e17d8a3b19740a448dedf220d0f7ba9c61d31/src/components/LFeatureGroup.vue#L27
Take note of the following line:
this.parentContainer.addLayer(this);
In this context, this
points to an instance of the Vue component l-feature-group
, while the true Leaflet FeatureGroup
can be found in the this.mapObject
property.
I recommend using the l-feature-group
component instead. For example:
<l-map
id="mapid"
:zoom="zoom"
:center="center"
>
<l-feature-group>
<!-- relevant children -->
</l-feature-group>
</l-map>
A useful example can be found in the documentation:
I also advise against using
document.getElementById("mapid").__vue__
to access the Vue instance. Instead, utilize
ref
and
$refs
.