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

viewer.flyTo(entities) or viewer.zoomTo(entities) #365

Open
mugeusta opened this issue Dec 30, 2020 · 3 comments
Open

viewer.flyTo(entities) or viewer.zoomTo(entities) #365

mugeusta opened this issue Dec 30, 2020 · 3 comments

Comments

@mugeusta
Copy link

I have an issue with the angular-cesium library. The issue is about the viewer.flyTo(entities) method in the library. It only works one-time on a cesium map. Unless I reload the page(cesium map) by pressing F5, it doesn't work again.

I don't know if it is a caching issue or not. If it is, how to solve this problem? Could you mind helping me with this issue?

@bampakoa
Copy link
Contributor

bampakoa commented Jan 5, 2021

@mugeusta can you share any details about how you invoke the second call to the flyTo method? I created a simple demo with a setTimeout and it works correctly. Below is the code that I used for your reference:

ngOnInit() {
  const viewer = this.cesiumService.getViewer();
  viewer.camera.flyTo({destination: this.Cesium.Cartesian3.fromDegrees(-90.0, 40.0, 1000000)});

  setTimeout(() => {
    viewer.camera.flyTo({destination: this.Cesium.Cartesian3.fromDegrees(-190.0, 40.0, 1000000)});
  }, 6000);
}

@danielRadiceski
Copy link

Hi @bampakoa , thank you for the example above. I tried the same in my app but I also didn't have luck.

I got this error:

ERROR TypeError: Cannot read property 'camera' of undefined
at GeocirrusViewerComponent.ngOnInit (geocirrus-viewer.component.ts:62)
at callHook (core.js:2481)
at callHooks (core.js:2451)
at executeInitAndCheckHooks (core.js:2403)
at refreshView (core.js:9186)
at refreshEmbeddedViews (core.js:10278)
at refreshView (core.js:9195)
at refreshComponent (core.js:10324)
at refreshChildComponents (core.js:8968)
at refreshView (core.js:9221)

I just injected the CesiumService into my component. Do you have any suspicions what might be the problem? Maybe you can share your whole demo there to see if there is any set up error on my side?

Please find attached my component file.

Thank you.
component.txt

@bampakoa
Copy link
Contributor

bampakoa commented Feb 3, 2021

@danielRadiceski I suspect that your case is a bit different. Use the viewModifier function for interacting with the camera instead:

 viewerConf.viewerModifier = (viewer: any) => {
      viewer.camera.flyTo({destination: Cesium.Cartesian3.fromDegrees(-90.0, 40.0, 1000000)});

      setTimeout(() => {
        viewer.camera.flyTo({destination: Cesium.Cartesian3.fromDegrees(-190.0, 40.0, 1000000)});
      }, 6000);

      // Remove default double click zoom behaviour
      viewer.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
    };

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

No branches or pull requests

3 participants