-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin.html
54 lines (41 loc) · 1.06 KB
/
plugin.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<plugin>
<!-- this Plugin does not have any HTML content -->
<script>
// Windy API modules are imported via '@windy/nameOfModule'
import map from '@windy/map'
/*
This part of code will be executed just once, since
plugin remains 'mounted' in a page even after closing
*/
console.log('I am being mounted')
let popup = null
// this.onopen method is called when your plugin is being opened
this.onopen = () => {
const center = map.getCenter()
/*
this.ononpen method can be called repeatedly (without your plugin
being closed before), so make sure, that you will not to subscribe
to any listener twice
*/
if( popup ) {
popup.setLatLng(center)
} else {
popup = L.popup()
.setLatLng(center)
.setContent("Hello World")
.openOn( map );
}
}
/*
this.onclose method is called when your plugin is being closed
Unsubscribe from all your listeners, and remove all your
stuff from a map
*/
this.onclose = () => {
if( popup ) {
map.removeLayer( popup )
popup = null
}
}
</script>
</plugin>