I'm implementing the option to return to the last position with cookies but I don't know how to set the last resolution.

Here part of the code:

if (setPos) {
  var setPos = sessionStorage.getItem('mappos').split(',');
  view.centerOn( [setPos[0], setPos[1]] , map.getSize(), [($(window).innerWidth()/2), ($(window).innerHeight()/2)]);


} else {
    var tmp = getUserPrefs();
    if (tmp != null) {
      var urlpos = window.location.search.replace( "?", "" );

    if (urlpos.search('defpos') == -1) {
            sDefPos = tmp;
            var setPos = sDefPos.split(',');
  } else {
      var setPos = twSettings.defpos.split(',');

view.setResolution() it works but then if I move the zoom the map disappears and I have to delete the browser history to have it back.

There is a way to set the last zoom level and maintain the resolutions array I have in the view and be able to continue exploring the map?


The solution was:


It seems that centerOn accept the number in the array but setResolution doesn't recognize that number as a number.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.