-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpcars_map_controller.js
186 lines (151 loc) · 4.73 KB
/
pcars_map_controller.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/* the class pcars_map_controller should be a generic wrapper for different map types: google, bing, osm, ...
* and provides a standard set of function to
* - init an new map incl. loading required modules
* - set basic settings
* - switch between map types
* - clean deletion of map objects
* - error handling, API Key handling, ...
*/
class pcars_map_controller extends PCARSLV_BASIC {
// example function header
/*
* param {string}
* param {object}
* param {int}
*
* return {string} true if all is fine, false if something went wrong
*/
/* constructor()
*
* param {string} sMaptype defines the type of map: GOOGLE | BING | OSM | ...
* param {string} sMapHtmlId defines the HTML object ID whre map should be displayed
* param {array} aMapSettings includes all relevant map settings in a key-value pair
* return {boolean} true if all is fine, false if something went wrong
*/
constructor(sMaptype, sMapHtmlId, aMapSettings) {
super(); // get functions from basic class
this._sMapType = sMaptype;
this._sMapHtmlID = sMaptype;
this.oCurMapObj = undefined;
this.circuitID = -1; //used for refpoint fiddling window, if you click on a circuit in the tracklist table. In this case the circuit ID of the selected table row is set
switch (sMaptype) {
// GOOGLE
case "google":
this.oCurMapObj = new pcars_map_google(sMaptype, sMapHtmlId, aMapSettings);
if(log >= 3){console.log("TODO pcars_map_controller.constructor() call for google!" , this);}
if (typeof this.oCurMapObj == 'object'){
}
break;
//Text
case "text":
break;
//Raw
case "raw":
this.oCurMapObj = new pcars_map_raw(sMaptype, sMapHtmlId, aMapSettings);
if(log >= 3){console.log("SICECKHA TODO pcars_map_raw initialized!" , this);}
break;
//BING
case "bing":
break;
//OSM
case "osm":
break;
// returns the initialized object
//return this.oCurMap;
return this.oCurMapObj;
}
}
/* returns all available map types
*
* return {array} array of map types
*/
getMapTypes(){
var aMapTaypes =
{ 'google':
{
'value': 'google',
'display_value': 'Google Maps',
},
'text':
{
'value': 'text',
'display_value': 'Text (placebo)',
},
'raw':
{
'value': 'raw',
'display_value': 'Raw',
},
'bing':
{
'value': 'bing',
'display_value': 'Bing Maps (placebo)'
},
'osm1':
{
'value': 'osm_bikemap',
'display_value': 'OSM Bike Map (placebo)'
}
};
return aMapTaypes;
}
/* Implementation todos
* changeMapType()
* updateMarker()
* deleteAllMarker()
* pauseMarker()
* changeMapSettings()
*
*
* _destroyCurrentMap()
*
*/
/* changeMapType()
*
* param {object} newTrackObj with map settings
* return {boolean} true if all is fine, false if something went wrong
*/
init_map(newTrackObj ){
return this.oCurMapObj.init_map(newTrackObj);
}
/* TODO
* changeMapType()
*
* param {string}
* param {array}
* return {boolean} true if all is fine, false if something went wrong
*/
changeMapType( sNewMapType, aMapSettings){
return true;
}
/* updateMarker() - place holder function
*
* param {array}
* return {boolean} true if all is fine, false if something went wrong
*/
updateMarker(aMarkerObject){
return this.oCurMapObj.updateMarker(aMarkerObject);
}
/* TODO
* changeMapSettings() -
*
* param {array}
* return {boolean} true if all is fine, false if something went wrong
*/
changeMapSettings(newTrackObj, mapobj, trackid){
//if(log >= 3){console.log("TODO pcars_map_controller.changeMapSettings() called", this);}
// if (this.oCurMapObj && this.oCurMapObj.isReady()){
return this.oCurMapObj.changeMapSettings(newTrackObj, mapobj, trackid);
// }
}
/* TODO
* changeMapSettings() -
*
* param {array}
* return {boolean} true if all is fine, false if something went wrong
*/
interruptTransition(){
this.oCurMapObj.interruptTransition();
return true;
}
};