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

Issue #954: Balloon Widget #982

Closed
wants to merge 38 commits into from
Closed

Issue #954: Balloon Widget #982

wants to merge 38 commits into from

Conversation

hpinkos
Copy link
Contributor

@hpinkos hpinkos commented Jul 26, 2013

Issue #954

Balloon will display above primitives that have the property balloon (storing the content of the balloon as a string), and either the function computeScreenSpacePosition or getPosition (to tell the balloon where to be positioned on screen)

note: sanitation of the HTML balloon content still needs to be done

*
* @type {Object}
*/
pickObject: {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think that this function should exist here because it is too high-level. The BalloonViewModel should just have a position property, which is the real-world position of the Balloon. The calling code should be responsible for both setting the position and the element to display.

@hpinkos
Copy link
Contributor Author

hpinkos commented Jul 30, 2013

@mramato alright, I changed the view model to accept a position instead

*
* @param {Cartesian3} position The cartesian position
*
* @returns {Cartesain2} The screen coordinates of the given position;
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: Cartesain2

Copy link
Contributor

Choose a reason for hiding this comment

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

Also should have a period instead of a semicolon at the end.

@mramato
Copy link
Contributor

mramato commented Jul 30, 2013

Merge in master when you get a chance.

@mramato
Copy link
Contributor

mramato commented Jul 30, 2013

I think there was confusion with my last comment. BalloonViewModel.position should be a Cartesian3 world position and not a screen space position.

this._contentElement = contentElement;
this._content = contentElement.innerHTML;
this._position = undefined;
this._computeScreenSpacePosition = scene.computeScreenSpacePosition;
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be a wrapped around a closure, you can't assign scene.computeScreenSpacePosition directly because it is a prototype function.

this._computeScreenSpacePosition = function(position, result) {
  return scene.computeScreenSpacePosition(position, result);
}

To have it work properly with DynamicObjects.

I also changed the max width/height of the balloon to be much bigger.
@hpinkos
Copy link
Contributor Author

hpinkos commented Aug 2, 2013

@mramato I fixed the balloon position behavior in 2D and CV. I changed the default computeScreenSpace function in BalloonViewModel to SceneTransforms.wgs84ToWindowCoordinates. I stripped the computeScreenSpace function out of Scene because this function is specific to WGS84.

@mramato
Copy link
Contributor

mramato commented Aug 5, 2013

Cool, I was unaware SceneTransforms.wgs84ToWindowCoordinates existed. Can you merge in master when you get a chance.

hpinkos added 2 commits August 5, 2013 11:30
Conflicts:
	Source/Widgets/Viewer/viewerDynamicObjectMixin.js
*/
computeScreenSpacePosition: {
set: function(value) {
if (typeof value === 'function') {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would just remove this check. If anything we would throw, but for the most part I would argue that we don't need to check at all. If the user sets a non-function, it will just cause an exception when the balloon is updated.

mramato and others added 6 commits August 6, 2013 13:40
1. Improve GeoJsonDataSource balloon.
2. Make balloon work in all cases in the Viewer.
3. Make the balloon go away when data goes away.
4. Add Balloon.css to widgets.css
5. Misc clean up to viewerDynamicObjectMixin
Conflicts:
	Source/Widgets/Balloon/BalloonViewModel.js
Clean up Viewer balloon usage
var posX;
var posY;

var containerWidth = viewModel._container.clientWidth;
Copy link
Contributor

Choose a reason for hiding this comment

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

The general rule in Cesium is that if you use a property more than once, you should extract it out into a local. So declare var container = viewModel._container and replace your usage of it throughout this function. It will make the code easier to read and also improves performance.

hpinkos added 4 commits August 7, 2013 13:43
Conflicts:
	Source/Widgets/Viewer/viewerDynamicObjectMixin.js
	Specs/Widgets/Viewer/viewerDynamicObjectMixinSpec.js
@pjcozzi
Copy link
Contributor

pjcozzi commented Aug 29, 2013

What's the plan here?

@hpinkos merge in master once in a while to get this PR fresh.

@mramato
Copy link
Contributor

mramato commented Aug 29, 2013

@hpinkos did an awesome job getting us mostly there. There are a few open questions I need to think about in terms of how this works with DynamicObjects, so I'll probably branch this branch and work on it sometime soon. I definitely expect this to be done within a couple weeks, if not sooner.

@mramato
Copy link
Contributor

mramato commented Sep 10, 2013

@hpinkos Thanks for the awesome job of getting this off of the ground. Since you have commit access now, and we want to experiment with the some more before it goes into master, I'm going to close this pull request and open up a balloon branch in cesium proper. I'll also merge in master and we'll hopefully get this into main in a couple of weeks. I'll nag you if I have any questions about the code. Thanks again.

@mramato mramato closed this Sep 10, 2013
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.

5 participants