-
Notifications
You must be signed in to change notification settings - Fork 361
/
Copy pathVelocity.js
65 lines (61 loc) · 1.64 KB
/
Velocity.js
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
55
56
57
58
59
60
61
62
63
64
65
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
const L = require('../leaflet.js');
const layer = require('./Layer.js');
const utils = require('../utils');
export class LeafletVelocityModel extends layer.LeafletLayerModel {
defaults() {
return {
...super.defaults(),
_view_name: 'LeafletVelocityView',
_model_name: 'LeafletVelocityModel',
displayValues: true,
displayOptions: {
velocityType: 'Global Wind',
position: 'bottomleft',
emptyString: 'No velocity data',
angleConvention: 'bearingCW',
displayPosition: 'bottomleft',
displayEmptyString: 'No velocity data',
speedUnit: 'kt',
},
data: [],
minVelocity: 0,
maxVelocity: 10,
velocityScale: 0.005,
colorScale: [],
caption:''
};
}
}
export class LeafletVelocityView extends layer.LeafletLayerView {
create_obj() {
var options = this.get_options();
options.data = this.model.get('data');
this.obj = L.velocityLayer(options);
}
model_events() {
super.model_events();
this.listenTo(
this.model,
'change:data',
function () {
const data = this.model.get('data');
this.obj.setData(data);
},
this
);
// Separate display_options from the options to perform a shallow copy.
var key = 'display_options';
this.listenTo(
this.model,
'change:' + key,
function () {
var options = {};
options[utils.camel_case(key)] = { ...this.model.get(key) };
L.setOptions(this.obj, options);
},
this
);
}
}