Change time zone and default position of the globe

Hi,

once Cesium is launched, the globe always centers on America.

Does anyone know how I can change this to my location? Or preferably the country where I am located is centered? I already get the GEO data. I just don’t know where exactly in the Cesium I could enter the GEO data.

I would also adjust the time zone. The time zone is wrong for me. Again, I would want to make it location specific. Unfortunately I don’t know how either.

I can’t find any reasonable examples on the internet. So I would be very happy if someone could help me here.

Thanks in advance for the trouble.

Hi,

  • You may use HTML Geolocation to get browser’s location and set it to default camera position as recommended by emacky on this stackoverflow post.

You may check this similar post.

You can also change viewer’s current time like:
viewer.clock.currentTime = new Cesium.JulianDate(2457522.154792);

I hope it would be helpful to you.

  • Regards,

Hi @Jacky,

I thank you for the support.

Yes, the geolocation is easy, I had that far, but didn’t know how I could hand it over to the Cesium.
I checked out your post for this, but haven’t tried it yet.
There in the example a rectangle is formed and 3 coordinates are transferred. This will then open
“Cesium.Camera.DEFAULT_VIEW_RECTANGLE”.

Why is the JulianDate used here and not the normal calendar?

I’ll try the whole thing and report back if necessary.
I thank you for the help.

Hello,

I need help and support again.
I managed to do that with the time zone, but I couldn’t solve the fact that the standard position of the globe points to my location.

I’ve tried many things.
What I’ve managed to do so far is this:

Here I have the problem that when the camera starts, it turns to my location. However, it should be accepted directly as the default value and the home button should also be positioned on my location.

Which I also don’t know how the “heigt” should be.
In order to look at the earth more or less from space, I set the “height” value to 15 million. I don’t know what the right height is here. Couldn’t figure that out from the documentation.

I ask for help. I don’t get it and I don’t know how to go about it.

thanks in advance

Why aren’t there any answers here?
I’m sure I didn’t ask a complicated question, did I?

I can’t say why the camera is flying again to the same location as you’ve not shared any sandcastle example.
I think you need to play with camera position. You can get current position of the camera and then multiply that position’s height and set it back to the camera. Check my reply on this post for detail.

Hello Jackie,

well I don’t know how to create a sandcastle example. Delivering the entire project to the sand castle is stupid too.

It would be very helpful to me if you could give a working example, which I can then take over.

When the earth starts, it is not in my location. Here’s what happens with the code above, which I shared here last time: when the earth takes off, it first shows America, and then it flies to my location.
It should take over my location directly.

As for the height, I think you misunderstood me. I couldn’t quite understand your code/example in advance.
So the following again:
When the earth starts it has a standard view, doesn’t it?
The earth is viewed from space. To do the same thing I asked for the amount because at 15 million I don’t look at it like it was in the original state. I don’t understand why these standard values ​​are not entered anywhere.

Can someone tell me how I can show the standard position of the earth on my location?

Please help!

You can put this line directly after initializing viewer:

viewer.camera.setView({
      destination: Cesium.Cartesian3.fromDegrees(yourlocation_lon, yourlocation_lat, yourlocation_alt)
});

Use zoomTo instead of flyTo if you want to zoom to any location without flying the camera.

Hello Jackie,

Thanks for the answer.
yes it worked But I still have 2 questions and would be very happy if I could get a detailed answer.

  1. what is the default height value (see “yourlocation_alt” in your code)

  2. Now when I click on the home button, it still turns to America. I want to avoid that. Here I would also set the home button on my location.

What is the default home button command?
It didn’t work with the posts above. Therefore, I ask the question here again and hope that I could get a solution for it.

Thanks in advance.

I’m not sure what is the default height value(that can be any value that you’ve set). Default camera position (WC) on a blank sandcastle is:
{lon: -82.5, lat: 35.15971103304566, alt: 19356453.597644374}

You can set Default cam location on home button also like:

var default_location = {lon: 83.552, lat: 30.328, alt: 8412134};

viewer.camera.setView({
    destination: Cesium.Cartesian3.fromDegrees(default_location.lon, default_location.lat, default_location.alt)
});

viewer.homeButton.viewModel.command.beforeExecute.addEventListener(
  function (e) {
      e.cancel = true;
      viewer.camera.setView({
      destination: Cesium.Cartesian3.fromDegrees(default_location.lon, default_location.lat, default_location.alt)
      });
      /* If want to fly camera*/
      /*
      viewer.camera.flyTo({
          destination: Cesium.Cartesian3.fromDegrees(default_location.lon, default_location.lat, default_location.alt)
      });
      */
});

Example

Oh okay, then this must be the default position or alt: 19356453.597644374} the default height. It’s a shame it’s not in the docs. At least I couldn’t find it…

Thanks to you, I was also able to solve the problem with the home button. It wasn’t that complicated… I really only thought it was extremely complicated… Well, my beginner’s mistakes.

No worries, we are here to help you out. :slightly_smiling_face:

1 Like