Skip to content

Commit c1cee13

Browse files
committed
adds layer-added and layer-removed events
1 parent dfbfdff commit c1cee13

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

docs/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,6 @@ The following default values can be overridden by passing an object to the `pain
230230
}
231231
```
232232

233-
Additional Functionality
234-
------------------------
235-
Please use the issues tracker to request exposing any additional functionality.
233+
A `@layer-added` event, with layer uid as parameter, is emitted when the layer has been added to the map. This information can be used for subsequent interaction with the layer, such as adding layer specific events.
234+
235+
A `@layer-removed` event, again with layer uid as parameter, is emitted when the layer has been removed.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-mapbox-feature",
3-
"version": "0.10.2",
3+
"version": "0.10.3",
44
"description": "A minimalist Vue component for displaying dynamic geojson on a Mapbox GL JS map.",
55
"scripts": {
66
"lint": "vue-cli-service lint",

src/components/VueMapboxFeature.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ export default {
351351
'delay': 0
352352
}
353353
}, this.behindLayer)
354+
// return the layer for reference from parent component
355+
this.$emit('layer-added', this.uid)
354356
} else {
355357
console.warn('NOTE -> unable to set feature collection geom')
356358
}
@@ -399,6 +401,7 @@ export default {
399401
},
400402
cleanup () {
401403
if (this.map && this.map.getLayer(this.uid)) {
404+
this.$emit('layer-removed', this.uid)
402405
this.map.removeLayer(this.uid)
403406
}
404407
if (this.map && this.map.getSource(this.uid)) {

0 commit comments

Comments
 (0)