DragnDrop.js 8.64 KB
Newer Older
Patrick's avatar
Patrick committed
1
2
var startend = ""

patri's avatar
patri committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// function preload(arrayOfImages) {
//   $(arrayOfImages).each(function(){
//       $('<img/>')[0].src = this;
//       // Alternatively you could use:
//       // (new Image()).src = this;
//   });
// }

// // Usage:

// preload([
//   '../datasource-data/NoiseData/Icons_soundquiz/s_noise_spacecadet.png',
//   '../datasource-data/NoiseData/Icons_soundquiz/s_noise_paologreen.png',
//   '../datasource-data/NoiseData/Icons_soundquiz/s_noise_rosybrown.png'
// ]);







Patrick's avatar
Patrick committed
25
26
27
function dragstart_handler(e){
    var img = new Image();
    img.src = '../templates/locationSMsmall.png';
patri's avatar
patri committed
28
29

    e.dataTransfer.setDragImage(img, 11, 24);    
Patrick's avatar
Patrick committed
30
31
    // e.dataTransfer.setDragImage(img, 75, 145); 
}
Patrick's avatar
Patrick committed
32
function dragstart_handler_quiz1(e){
patri's avatar
patri committed
33
34
35
  // var img = new Image();
  // img.src = '../datasource-data/NoiseData/Icons_soundquiz/s_noise_spacecadet.png';
  // e.dataTransfer.setDragImage(img, 23, 45);    
Patrick's avatar
Patrick committed
36
37
38
  // e.dataTransfer.setDragImage(img, 75, 145); 
}
function dragstart_handler_quiz2(e){
patri's avatar
patri committed
39
40
41
  // var img = new Image();
  // img.src = '../datasource-data/NoiseData/Icons_soundquiz/s_noise_paologreen.png';
  // e.dataTransfer.setDragImage(img, 23, 45);    
Patrick's avatar
Patrick committed
42
43
44
  // e.dataTransfer.setDragImage(img, 75, 145); 
}
function dragstart_handler_quiz3(e){
patri's avatar
patri committed
45
46
47
  // var img = new Image();
  // img.src = '../datasource-data/NoiseData/Icons_soundquiz/s_noise_rosybrown.png';
  // e.dataTransfer.setDragImage(img, 23, 45);    
Patrick's avatar
Patrick committed
48
49
50
  // e.dataTransfer.setDragImage(img, 75, 145); 
}
function dragstart_handler_quiz4(e){
patri's avatar
patri committed
51
52
53
  // var img = new Image();
  // img.src = '../datasource-data/NoiseData/Icons_soundquiz/s_noise_rosevale.png';
  // e.dataTransfer.setDragImage(img, 23, 45);    
Patrick's avatar
Patrick committed
54
55
56
  // e.dataTransfer.setDragImage(img, 75, 145); 
}
function dragstart_handler_quiz5(e){
patri's avatar
patri committed
57
58
59
  // var img = new Image();
  // img.src = '../datasource-data/NoiseData/Icons_soundquiz/s_noise_myrtlegreen.png';
  // e.dataTransfer.setDragImage(img, 23, 45);    
Patrick's avatar
Patrick committed
60
61
62
  // e.dataTransfer.setDragImage(img, 75, 145); 
}
function dragstart_handler_quiz6(e){
patri's avatar
patri committed
63
64
65
  // var img = new Image();
  // img.src = '../datasource-data/NoiseData/Icons_soundquiz/s_noise_babyblue.png';
  // e.dataTransfer.setDragImage(img, 23, 45);    
Patrick's avatar
Patrick committed
66
67
68
  // e.dataTransfer.setDragImage(img, 75, 145); 
}
function dragstart_handler_quiz7(e){
patri's avatar
patri committed
69
70
71
  // var img = new Image();
  // img.src = '../datasource-data/NoiseData/Icons_soundquiz/s_noise_rubyred.png';
  // e.dataTransfer.setDragImage(img, 23, 45);    
Patrick's avatar
Patrick committed
72
73
74
  // e.dataTransfer.setDragImage(img, 75, 145); 
}
function dragstart_handler_quiz8(e){
patri's avatar
patri committed
75
76
77
  // var img = new Image();
  // img.src = '../datasource-data/NoiseData/Icons_soundquiz/s_noise_greensheen.png';
  // e.dataTransfer.setDragImage(img, 23, 45);    
Patrick's avatar
Patrick committed
78
79
80
  // e.dataTransfer.setDragImage(img, 75, 145); 
}

Patrick's avatar
Patrick committed
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101

function dragEnter(e){

    
    var map = vcs.vcm.Framework.getInstance().getActiveMap();
var viewer = map.getCesiumWidget()
var scene = map.getCesiumWidget()._scene

// var scene = viewer.scene;
var billboards = scene.primitives.add(new Cesium.BillboardCollection());

   event.preventDefault();
   return true;
}

function dragDrop(e) {

  var map = vcs.vcm.Framework.getInstance().getActiveMap();
  var viewer = map.getCesiumWidget()
  var scene = map.getCesiumWidget()._scene

patri's avatar
patri committed
102
103
104
105
  // stop Firefox from executing its default behaviour
  if(e.preventDefault) { e.preventDefault(); }
    if(e.stopPropagation) { e.stopPropagation(); }

Patrick's avatar
Patrick committed
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
// var scene = viewer.scene;
// var billboards = scene.primitives.add(new Cesium.BillboardCollection());

    // var canvas = document.createElement('canvas');
    // canvas.width = 32;
    // canvas.height = 32;
    // var ctx = canvas.getContext('2d');
    // ctx.beginPath();
    // ctx.arc(16, 16, 15, 0, Cesium.Math.TWO_PI, true);
    // ctx.closePath();
    // ctx.fillStyle = `hsl(${Math.random()*360},55%,55%)`;
    // ctx.fill();


    var cartesian = viewer.camera.pickEllipsoid(
      new Cesium.Cartesian3(e.clientX, e.clientY), 
      scene.globe.ellipsoid
    );

    // billboards.add({
    //   image: canvas,
    //   position: cartesian
    // });
    var cartographic = Cesium.Cartographic.fromCartesian(cartesian);
        console.log(cartographic)
        var longitudeString = Cesium.Math.toDegrees(
          cartographic.longitude
        );
        ballonContent.lon = longitudeString;
        var latitudeString = Cesium.Math.toDegrees(
          cartographic.latitude
        );
        ballonContent.lat = latitudeString;

    if (startend == "start"){
        var pointd = {
          lat:"",
          lon:"",
          loc:""
      }
          pointd.lat = ballonContent.lat
          pointd.lon = ballonContent.lon
          pointd.loc = "Start"
          var text = document.getElementById('Spunktlat');
          text.value = ballonContent.lat;
          var text = document.getElementById('Spunktlon');
          text.value = ballonContent.lon;
          // visualize a Point at the clicked location
          setPoint("Start", pointd);

      } else if (startend == "end"){
        var pointd = {
          lat:"",
          lon:"",
          loc:""
      }
          pointd.lat = ballonContent.lat
          pointd.lon = ballonContent.lon
          pointd.loc = "End"

          var text = document.getElementById('Epunktlat');
          text.value = ballonContent.lat;
          var text = document.getElementById('Epunktlon');
          text.value = ballonContent.lon;
          // visualize a Point at the clicked location
          setPoint("End", pointd);
      } else if (startend == "fav"){
        var pointd = {
          lat:"",
          lon:"",
          loc:""
      }
          pointd.lat = ballonContent.lat
          pointd.lon = ballonContent.lon
          pointd.loc = "fav"

          // var text = document.getElementById('Epunktlat');
          // text.value = ballonContent.lat;
          // var text = document.getElementById('Epunktlon');
          // text.value = ballonContent.lon;
          // visualize a Point at the clicked location
187
          setPointFav("fav", pointd);
Patrick's avatar
Patrick committed
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
        }else if (startend == "quiz_baustelle"){
          var pointd = {
            lat:"",
            lon:"",
            loc:""
        }
            pointd.lat = ballonContent.lat
            pointd.lon = ballonContent.lon
            pointd.loc = "quiz_baustelle"
            point_baustelle = pointd

            setPointFav("quiz_baustelle", pointd);
      }else if (startend == "quiz_pragfriedhof"){
        var pointd = {
          lat:"",
          lon:"",
          loc:""
      }
          pointd.lat = ballonContent.lat
          pointd.lon = ballonContent.lon
          pointd.loc = "quiz_pragfriedhof"
          point_pragfriedhof = pointd

          setPointFav("quiz_pragfriedhof", pointd);
      }else if (startend == "quiz_marktplatz"){
        var pointd = {
          lat:"",
          lon:"",
          loc:""
Patrick's avatar
Patrick committed
217
      }
Patrick's avatar
Patrick committed
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
          pointd.lat = ballonContent.lat
          pointd.lon = ballonContent.lon
          pointd.loc = "quiz_marktplatz"
          point_marktplatz = pointd

          setPointFav("quiz_marktplatz", pointd);
    }else if (startend == "quiz_skaten"){
      var pointd = {
        lat:"",
        lon:"",
        loc:""
    }
        pointd.lat = ballonContent.lat
        pointd.lon = ballonContent.lon
        pointd.loc = "quiz_skaten"
        point_skaten = pointd

        setPointFav("quiz_skaten", pointd);
  }else if (startend == "quiz_kirche"){
    var pointd = {
      lat:"",
      lon:"",
      loc:""
  }
      pointd.lat = ballonContent.lat
      pointd.lon = ballonContent.lon
      pointd.loc = "quiz_kirche"
      point_kirche = pointd

      setPointFav("quiz_kirche", pointd);
}else if (startend == "quiz_meerschweinchen"){
  var pointd = {
    lat:"",
    lon:"",
    loc:""
}
    pointd.lat = ballonContent.lat
    pointd.lon = ballonContent.lon
    pointd.loc = "quiz_meerschweinchen"
    point_meerschweinchen = pointd

    setPointFav("quiz_meerschweinchen", pointd);
}else if (startend == "quiz_ufapalast"){
  var pointd = {
    lat:"",
    lon:"",
    loc:""
}
    pointd.lat = ballonContent.lat
    pointd.lon = ballonContent.lon
    pointd.loc = "quiz_ufapalast"
    point_ufapalast = pointd

    setPointFav("quiz_ufapalast", pointd);
}else if (startend == "quiz_rostensteinpark"){
  var pointd = {
    lat:"",
    lon:"",
    loc:""
}
    pointd.lat = ballonContent.lat
    pointd.lon = ballonContent.lon
    pointd.loc = "quiz_rostensteinpark"
    point_rosensteinpark = pointd

    setPointFav("quiz_rostensteinpark", pointd);
}
Patrick's avatar
Patrick committed
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
}

function dragOver(e){
    var map = vcs.vcm.Framework.getInstance().getActiveMap();
var viewer = map.getCesiumWidget()
var scene = map.getCesiumWidget()._scene


// var scene = viewer.scene;
var billboards = scene.primitives.add(new Cesium.BillboardCollection());
   e.preventDefault();
}



function setPointStartEnd(loc){
startend = loc
patri's avatar
patri committed
302
303
304
305
}