Skip to content

Commit 3ca29a5

Browse files
committed
Watches options change and refresh the component
1 parent 81d637d commit 3ca29a5

10 files changed

+39
-26
lines changed

.DS_Store

0 Bytes
Binary file not shown.

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2727
2828
-->
2929

30+
## [v0.3.1] - 2020-10-16
31+
32+
- Added watcher for options and refresh the chart once it changes
33+
- Store a reference to the control added to the map and removes/re-add before refreshing the component
34+
based on options or data changes
35+
3036
## [v0.3.0] - 2020-10-08
3137

3238
Refactored, improved in-code documentation and added internal responsiveness and and close event.
3339

3440
## [v0.2.0] - 2020-08-05
3541

3642
### Added
43+
3744
- data watcher
3845
- changing the 'data' prop now rebuilds the graph without
3946
removing and adding the whole leaflet control by calling

dist/Vue2LeafletHeightGraph.common.js

Lines changed: 9 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/Vue2LeafletHeightGraph.common.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/Vue2LeafletHeightGraph.umd.js

Lines changed: 9 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/Vue2LeafletHeightGraph.umd.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/Vue2LeafletHeightGraph.umd.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/Vue2LeafletHeightGraph.umd.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue2-leaflet-height-graph",
3-
"version": "0.3.0",
3+
"version": "0.3.1",
44
"description": "Leaflet.Heightgraph plugin extension for vue2-leaflet package",
55
"main": "dist/Vue2LeafletHeightGraph.umd.min.js",
66
"scripts": {

src/vue2-leaflet-height-graph.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default {
1515
breakpointsOrder: ['xs', 'sm', 'md', 'lg', 'xl'],
1616
defaultParser: 'geoJson',
1717
defaultPosition: 'bottomright',
18-
ready: false
18+
controlRef: null
1919
}
2020
},
2121
components: {
@@ -54,6 +54,10 @@ export default {
5454
options.parser = options.parser || this.defaultParser
5555
options.position = options.position || this.defaultPosition
5656
return options
57+
},
58+
mapObject () {
59+
const map = this.$parent.mapObject
60+
return map
5761
}
5862
},
5963
methods: {
@@ -62,14 +66,13 @@ export default {
6266
* the map and set the close button watcher
6367
*/
6468
loadData () {
65-
const map = this.$parent.mapObject
69+
const map = this.mapObject
6670
let heightGraphOptions = this.buildHeightGraphOptions()
6771
this.hgInstance = this.leafletAcessor.control.heightgraph(heightGraphOptions)
68-
this.hgInstance.addTo(map)
72+
this.controlRef = this.hgInstance.addTo(map)
6973
this.addData(this.data)
7074
this.isOpen = true
7175
this.watchCloseClick()
72-
this.ready = true
7376
},
7477
/**
7578
* Add data to the component
@@ -230,7 +233,7 @@ export default {
230233
if (this.hgInstance) {
231234
this.hgInstance.remove()
232235
this.isOpen = false
233-
this.ready = false
236+
this.controlRef = null
234237
}
235238
},
236239
watch: {
@@ -244,11 +247,10 @@ export default {
244247
},
245248
'options': {
246249
handler: function () {
247-
this.ready = false
250+
this.mapObject.removeControl(this.controlRef)
248251
let context = this
249252

250253
setTimeout(() => {
251-
context.ready = true
252254
context.loadData()
253255
}, 100)
254256
},

0 commit comments

Comments
 (0)