如何使用 Cesium.js 和 Google Map API 单击建筑物/地形时获取海拔

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

提问人:Ahmad Habibi 提问时间:10/13/2023 更新时间:10/13/2023 访问量:31

问:

目前,我通过单击自动完成搜索输入来获得提升。

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;
  }

有没有办法通过点击Cesium.js中的建筑物或地形来获得高程?

我也试图从这个 PR 中理解并阅读文档,但它无济于事

铯JS 谷歌街景 google-elevation-api

评论


答: 暂无答案