UserBalloon.js 2.35 KB
Newer Older
Patrick's avatar
Patrick committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
var ballonContent = {
    header: "Test",
    Content: "This is a test",
    lat: "",
    lon: "",
    categorie: ""
  }
  var point = {
      lat:"",
      lon:"",
      loc:""
  }


Patrick's avatar
Patrick committed
15
// Get Position from clicking on the map
Patrick's avatar
Patrick committed
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
function getPosition() {
    var map = vcs.vcm.Framework.getInstance().getActiveMap();
    var CViewer = map.viewer
    var CScene = map.viewer.scene
    if (document.getElementById("Navigation").style.display == "block"){
    // Mouse over the globe to see the cartographic position
    handler = new Cesium.ScreenSpaceEventHandler(CScene.canvas);
    handler.setInputAction(function (movement) {
      var cartesian = CViewer.camera.pickEllipsoid(
        movement.position,
        CScene.globe.ellipsoid
      );
      if (cartesian) {
          console.log(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 (pointsoe == "Start"){
Patrick's avatar
Patrick committed
42
43
44
45
46
47
48
49
          var pointd = {
            lat:"",
            lon:"",
            loc:""
        }
            pointd.lat = ballonContent.lat
            pointd.lon = ballonContent.lon
            pointd.loc = "Start"
Patrick's avatar
Patrick committed
50
51
52
53
            var text = document.getElementById('Spunktlat');
            text.value = ballonContent.lat;
            var text = document.getElementById('Spunktlon');
            text.value = ballonContent.lon;
Patrick's avatar
Patrick committed
54
55
            // visualize a Point at the clicked location
            setPoint("Start", pointd);
Patrick's avatar
Patrick committed
56
57

        } else if (pointsoe == "End"){
Patrick's avatar
Patrick committed
58
59
60
61
62
63
64
65
          var pointd = {
            lat:"",
            lon:"",
            loc:""
        }
            pointd.lat = ballonContent.lat
            pointd.lon = ballonContent.lon
            pointd.loc = "End"
Patrick's avatar
Patrick committed
66
67
68
69
70

            var text = document.getElementById('Epunktlat');
            text.value = ballonContent.lat;
            var text = document.getElementById('Epunktlon');
            text.value = ballonContent.lon;
Patrick's avatar
Patrick committed
71
72
            // visualize a Point at the clicked location
            setPoint("End", pointd);
Patrick's avatar
Patrick committed
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
        }


      } else {
        
      }
    }, Cesium.ScreenSpaceEventType.LEFT_CLICK)


    }


    

}