How to get elevation when click on building/terrain with Cesium.js and Google Map API

81 Views Asked by At

Currently I get elevation by click on autocomplete search input.

async function searchByAddressHandler( place_id ) {
    await geocoder
      .geocode( {placeId: place_id} )
      .then( async ( {results} ) => {
        if( results[ 0 ] ) {
          const elevationResponse = await elevationService.getElevationForLocations( {
            locations: [results[ 0 ].geometry.location],
          } );
          if( !(elevationResponse.results && elevationResponse.results.length) ) {
            useGrowl( 'error', `Insufficient elevation data for place: ${results[ 0 ].formatted_address}` )
          }
          const elv = elevationResponse.results[ 0 ].elevation;
          elevation = elv;
          resolution = elevationResponse.results[ 0 ].resolution
          rotateCameraAround(
            results[ 0 ].geometry.location,
            results[ 0 ].geometry.viewport,
            elv
          );
        } else {
          useGrowl( 'error', 'No result found' );
        }
      } ).catch( ( e ) => {
        useGrowl( 'error', `Geocoder failed due to: ${e}` );
      } );
    autocompleteLists = [];
    showAutoCompleteList = false;
  }

Is there any way to get elevation by click on building or terrain in Cesium.js ?

I also tried to understand from this PR and read docs but it cannot help

0

There are 0 best solutions below