var ballonContent = {
    header: "Test",
    Content: "This is a test",
    lat: "",
    lon: "",
    categorie: ""
  }
  var point = {
      lat:"",
      lon:"",
      loc:""
  }

var position_var = false;
// Get Position from clicking on the map
function setpositionVAR(vari){
  position_var = vari;
  if(vari == false){
    pointsoe = " "
  }
}
function getPosition() {
  var map = vcs.vcm.Framework.getInstance().getActiveMap();
  var CViewer = map.getCesiumWidget()
  var CScene = map.getCesiumWidget()._scene

  
    if (position_var == true){
    // 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"){
          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 (pointsoe == "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 {
        
      }
    }, Cesium.ScreenSpaceEventType.LEFT_CLICK)


    }


    

}