Cesiumjs – How to access the coordinates

phpmind-cesiumjs-access-the-coordinates

 var entities = dataSource.entities.values; 
                console.log("entities_positions"); 
                for (var i = 0; i < entities.length; i++) { 
                    entity =  entities[i]; 
                      var cartesianPositions = entity.polyline.positions; 
                      var cartographicPositions = viewer.scene.globe.ellipsoid.cartesianArrayToCartographicArray(cartesianPositions._value); 
                      var longitude = cartographicPositions[0].longitude; 
                      var latitude = cartographicPositions[0].latitude; 
                      var height = cartographicPositions[0].height; 
                      console.log(longitude); 
                      console.log(latitude); 

                } 

Those coordinates are given in radians. You can convert them back to degrees with Cesium.Math.toDegrees(radianValue).

Share

One thought on “Cesiumjs – How to access the coordinates

  1. Maria Saeed

    Hello. I want to search the data. like i have a kml file and if a user click on
    school it should fly to school area rather than showing all the polygons. I have
    seen your post on search and go but can u tell me how to search kml file in
    cesium . Your help will be highly appreciated

Leave a Reply

Your email address will not be published. Required fields are marked *