-
Notifications
You must be signed in to change notification settings - Fork 6
/
Model.js
77 lines (67 loc) · 1.75 KB
/
Model.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
66
67
68
69
70
71
72
73
74
75
76
77
define([
"dojo/_base/declare",
"dojo/_base/lang", // isObject
"./Placemark",
"./_base"
], function(declare, lang, Placemark, djeo) {
var dependency = "Model";
djeo.registerDependency(dependency, function(map){
return map.engine.canRenderModels;
});
var Model = declare([Placemark], {
constructor: function(/* Object? */featureDef, /* Object? */kwArgs) {
lang.mixin(this, kwArgs);
if (!lang.isObject(this.orientation)) {
var heading = this.orientation;
this.orientation = {
heading: heading === undefined ? 0: heading,
tilt: 0,
roll: 0
};
}
},
getCoordsType: function() {
return this.coordsType || "Point";
},
_render: function(theme, destroy) {
// set factory
if (!this.factory) {
var map = this.map;
if (map.engine.canRenderModels && map.renderModels) {
this.factory = map.engine.getFactory(dependency);
}
else this.factory = this.map.engine.factories.Placemark;
}
if (this.map.engine.canRenderModels && this.map.renderModels) {
// return Deferred
return this.factory.render(this);
}
else {
this.inherited(arguments);
}
},
_set_coords: function(coords) {
// convert coordinates to the map projection if it is relevant here
var _coords = this.map.getCoords(coords);
this.factory.setCoords(_coords, this);
this.coords = coords;
this._coords = _coords;
},
_set_orientation: function(orientation) {
var m = this.map;
if (m.engine.canRenderModels && m.renderModels) {
if (!lang.isObject(orientation)) {
orientation = {heading: orientation};
}
this.factory.setOrientation(orientation, this);
lang.mixin(this.orientation, orientation);
}
else {
this.inherited(arguments);
}
}
});
// register the constructor
djeo.featureTypes.Model = Model;
return Model;
});