Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Screen overlay #9864

Merged
merged 25 commits into from Oct 15, 2021
Merged

Screen overlay #9864

merged 25 commits into from Oct 15, 2021

Conversation

krupkad
Copy link
Contributor

@krupkad krupkad commented Oct 12, 2021

Fixes #9862.

This provides an MVP of KML ScreenOverlay support.

  • both external/URL images and bundled/kmz images are supported
  • rotation is not supported
  • enabled by passing a container element to KMLDataSource.load
  • "Cleaning up" the container is up to the user - no management of the created image elements is done here once they are created/positioned.

@cesium-concierge
Copy link

Thank you so much for the pull request @krupkad! I noticed this is your first pull request and I wanted to say welcome to the Cesium community!

The Pull Request Guidelines is a handy reference for making sure your PR gets accepted quickly, so make sure to skim that.

  • ❌ Missing CONTRIBUTORS.md entry.
  • ❌ Missing CLA.
  • CHANGES.md was not updated.
    • If this change updates the public API in any way, please add a bullet point to CHANGES.md.

Reviewers, don't forget to make sure that:

  • Cesium Viewer works.
  • Works in 2D/CV.
  • Works (or fails gracefully) in IE11.

Copy link
Contributor

@IanLilleyT IanLilleyT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - mostly small stuff to fix. Wondering if anyone else has thoughts on whether the screen overlay should be cleaned up by the caller vs automatic. @mramato @hpinkos

CHANGES.md Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
Source/DataSources/KmlDataSource.js Outdated Show resolved Hide resolved
Source/DataSources/KmlDataSource.js Outdated Show resolved Hide resolved
Source/DataSources/KmlDataSource.js Outdated Show resolved Hide resolved
Source/DataSources/KmlDataSource.js Outdated Show resolved Hide resolved
Source/DataSources/KmlDataSource.js Outdated Show resolved Hide resolved
Specs/DataSources/KmlDataSourceSpec.js Outdated Show resolved Hide resolved
@@ -3333,6 +3514,7 @@ function load(dataSource, entityCollection, data, options) {
* @property {Boolean} [clampToGround=false] true if we want the geometry features (Polygons, LineStrings and LinearRings) clamped to the ground.
* @property {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The global ellipsoid used for geographical calculations.
* @property {Credit|String} [credit] A credit for the data source, which is displayed on the canvas.
* @property {String} [screenOverlayContainer] A container for ScreenOverlay images. Note: this container is not managed, the caller is responsible for styling and removing unused overlay images.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is String the right type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems to be what other docs use for "pass in an element" options

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok I see how getElement.js will accept a string or an element

Source/DataSources/KmlDataSource.js Outdated Show resolved Hide resolved
@krupkad
Copy link
Contributor Author

krupkad commented Oct 13, 2021

@mramato I added the destroy method as discussed - turns out there is existing cleanup machinery in Source/DataSources/DataSourceCollection.js

@mramato
Copy link
Member

mramato commented Oct 13, 2021

@mramato I added the destroy method as discussed - turns out there is existing cleanup machinery in Source/DataSources/DataSourceCollection.js

Awesome, I thought we added something like that but wasn't completely sure.

@mramato
Copy link
Member

mramato commented Oct 13, 2021

Can we update the viewerDragDropMixin and Sandcastle demos to support screen overlays? I'm pretty sure at least one of our sample files already has one.

@hpinkos
Copy link
Contributor

hpinkos commented Oct 13, 2021

Do you think we should add a container for screen overlays that the Viewer creates that KmlDataSource can use by default if a container is not specified? How does Google Earth work?

@mramato
Copy link
Member

mramato commented Oct 13, 2021

Do you think we should add a container for screen overlays that the Viewer creates that KmlDataSource can use by default if a container is not specified?

viewerDragDropMix could do this but I'm not sure how it would work in Viewer itself since it doesn't know anything about KmlDataSource and isn't the one that creates it.

How does Google Earth work?

The web version doesn't have an API (and I'm not even sure it supports screen overlays). The desktop version has no customization either for similar reasons.

@hpinkos
Copy link
Contributor

hpinkos commented Oct 13, 2021

I'm not sure how it would work in Viewer itself since it doesn't know anything about KmlDataSource and isn't the one that creates it.

Right, I was thinking the viewer could create an element and KmlDataSource could getElementById to see if it happens to exist, which I'm assuming it would most of the time since I imagine most users create a Viewer. Or KmlDataSource could document.getElementByClassName('cesium-viewer') and add it's own screen overlay container to that div if it exists.

Just a thought. If we decide not to do this we might want to show a one time warning if the KML has a screen overlay and the user did not supply a screen overlay container.

@mramato
Copy link
Member

mramato commented Oct 13, 2021

I think that too closely couples everything together.

@hpinkos
Copy link
Contributor

hpinkos commented Oct 13, 2021

eh, maybe. I just thought it might make it easier for folks and make the default functionality more similar to google earth.

@krupkad
Copy link
Contributor Author

krupkad commented Oct 13, 2021

enabled screen overlays in both apps by passing the main container - seems to be working (though the overlay is under the toolbar in sandcastle)

@krupkad krupkad requested a review from hpinkos October 13, 2021 15:56
CHANGES.md Show resolved Hide resolved
Apps/CesiumViewer/CesiumViewer.js Outdated Show resolved Hide resolved
Source/DataSources/KmlDataSource.js Outdated Show resolved Hide resolved
Source/DataSources/KmlDataSource.js Outdated Show resolved Hide resolved
Source/DataSources/KmlDataSource.js Outdated Show resolved Hide resolved
Specs/DataSources/KmlDataSourceSpec.js Outdated Show resolved Hide resolved
Source/DataSources/KmlDataSource.js Outdated Show resolved Hide resolved
Specs/DataSources/KmlDataSourceSpec.js Outdated Show resolved Hide resolved
Specs/DataSources/KmlDataSourceSpec.js Outdated Show resolved Hide resolved
Source/DataSources/KmlDataSource.js Outdated Show resolved Hide resolved
@IanLilleyT
Copy link
Contributor

@hpinkos @mramato any final comments on the PR? I think it's just about ready to go

@hpinkos
Copy link
Contributor

hpinkos commented Oct 15, 2021

Nope, looks good to me

@IanLilleyT
Copy link
Contributor

Merged. Congrats on your first CesiumJS PR @krupkad!

Make sure to update #873 with any new information

@IanLilleyT IanLilleyT merged commit 4f557e6 into main Oct 15, 2021
@IanLilleyT IanLilleyT deleted the screen-overlay branch October 15, 2021 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

KML ScreenOverlay Support
5 participants