CesiumGS / cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:
https://cesium.com/cesiumjs/
Apache License 2.0
13k stars 3.5k forks source link

Add option to select which geocoder is used #12299

Closed angrycat9000 closed 2 hours ago

angrycat9000 commented 1 week ago

Description

Adds the ability to change the geocoder used.

Both Bing and Google have legal requirements that their geocoders should not be used with other data. Eg. Using Bing geocode results while showing Google 3D Tiles is not allowed.

Testing plan

  1. Run npm run start
  2. Open http://localhost:8080/Apps/Sandcastle/index.html
  3. Type in Philadelphia in the geocoder
    • Verify that multiple results are returned for Philadelphia
  4. Open http://localhost:8080/Apps/Sandcastle/index.html?src=Google%20Photorealistic%203D%20Tiles%20with%20Building%20Insert.html
  5. Type in Philadelphia in the geocoder
    • Verify that only a single result is returned
    • Verify that there is only a single google attribution at the bottom of the screen
  6. Open http://localhost:8080/Apps/Sandcastle/index.html?src=Bing%20Maps%20Labels%20Only.html
  7. Type in Philadelphia in the geocoder
    • Verify that multiple results are returned for Philadelphia
  8. Run the following code snippets in the local sandcastle and verify the results. Replace 'your-key-here` with a valid Google API key with Geocoding enabled
const viewer = new Cesium.Viewer("cesiumContainer", {
  geocoder: new Cesium.GoogleGeocoderService({
    key: 'your-key-here'
  })
});
const googleTileset = await Cesium.createGooglePhotorealistic3DTileset({
  onlyUsingWithGoogleGeocoder: true
});
viewer.scene.primitives.add(googleTileset);
const viewer = new Cesium.Viewer("cesiumContainer");
const googleTileset = await Cesium.createGooglePhotorealistic3DTileset();
viewer.scene.primitives.add(googleTileset);
const viewer = new Cesium.Viewer("cesiumContainer");
const googleTileset = await Cesium.createGooglePhotorealistic3DTileset('your-key-here');
viewer.scene.primitives.add(googleTileset);

Author checklist

github-actions[bot] commented 1 week ago

Thank you for the pull request, @angrycat9000!

:white_check_mark: We can confirm we have a CLA on file for you.

ggetz commented 1 week ago

Thanks @angrycat9000! We're hoping to take a review pass today.

angrycat9000 commented 1 week ago

Thanks @ggetz . Two things that were still pending:

ggetz commented 1 day ago

Hi @angrycat9000, I wanted to check in on the status of this PR as we are coming up on our next release soon.

  1. Are there any remaining TODO's for this PR?
  2. Is it at a point where it can come out Draft?
angrycat9000 commented 1 day ago

Hi @angrycat9000, I wanted to check in on the status of this PR as we are coming up on our next release soon.

  1. Are there any remaining TODO's for this PR?
  2. Is it at a point where it can come out Draft?

Just the discussion of how assertive to make the one time warning discussion. Added a to-do for that. Will be ready once that is decided.

angrycat9000 commented 19 hours ago

This is updated and ready for review again @ggetz

angrycat9000 commented 2 hours ago

Thanks for the feedback @ggetz . Updated and ready for another look

ggetz commented 2 hours ago

Fantastic! Thanks for contributing this @angrycat9000!