Trouble with restoring map extents using camera.flyto and destination as rectangle

Hi, I am experiencing a problem since upgrading to Cesium version 1.20 from Version 1.14. On my map, I am constantly storing the 4 corners of the screen as longitude and latitude positions in local storage so that if I leave the map and come back to it, I will be brought back to where I was looking. Since upgrading to version 1.20 of Cesium, I have lost this functionality. When I come back to my map page, I am brought to the bottom mid point of the map and I am zoomed in to about 5m from the map. I tried out my code in sandcastle and it does the exact same thing. Here is my sandcastle code below:

//var viewer = new Cesium.Viewer('cesiumContainer');
var viewer = new Cesium.Viewer('cesiumContainer', {
  //Play pause
  animation: false,
  //Bing layer picker
  baseLayerPicker: false,
  //Bing default provider
  imageryProvider : false,
  //Fullscreen button
  fullscreenButton: false,
  geocoder: false,
  //Home button
  homeButton : false,
  //Shows on first start
  infoBox: false,
  //3D, 2.5D, 2D
  sceneModePicker: false,
  //No idea
  selectionIndicator: false,
  timeline: false,
  navigationHelpButton: false,
  //Default to 2D Mode
  sceneMode: Cesium.SceneMode.SCENE2D,
  //Set map projection
  mapProjection : new Cesium.WebMercatorProjection()

function restoreExtents(){
    var restoreMyExtents = "29.389366816112982,-92.80960171047546,29.389366816112982,-92.78906207714422,29.369455253062277,-92.78906207714422,29.36945525306227,-92.80960171047546";

    if(restoreMyExtents == "null"){

    var positions = restoreMyExtents.split(",");
    if(positions.length == 1 || isNaN(positions[0])){
    var position1Cartesian = new Cesium.Cartographic.fromDegrees(positions[0], positions[1]);
    var position2Cartesian = new Cesium.Cartographic.fromDegrees(positions[2], positions[3]);
    var position3Cartesian = new Cesium.Cartographic.fromDegrees(positions[4], positions[5]);
    var position4Cartesian = new Cesium.Cartographic.fromDegrees(positions[6], positions[7]);

    var positionsArray = [position1Cartesian, position2Cartesian, position3Cartesian, position4Cartesian];

    var myView = Cesium.Rectangle.fromCartographicArray(positionsArray);{
        destination : myView,
        duration : 0



So, basically I have a function that converts my longitude and latitude points into an array of cartographic points which I then make into a rectangle that I can give to the camera flyto as a destination. This function is then added to the EventListener. The function also removes itself from the Eventlistener in its call so that the function is called only once on map load up. When I put a breakpoint in my code it seems like something else is being called after this in version 1.20 of Cesium which is causing my map to focus in on the mid bottom of the map.
Any ideas?


In your example, are you longitude and latitude values switched? It looks like you’re doing Cartographic.fromDegrees(lat, lon) instead of Cartographic.fromDegrees(lon, lat)

Also, you don’t need to use ‘new’ when using Cartographic.fromDegrees.



Thanks for the quick response. The and lat and lon were definitely swapped. Leads me to wonder when that happened though. Anyway, it's working now. Just gotta check every where else to make sure I don't have any others that are flipped.

Thanks Again!