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

Web Map Reload Scale #7

Open
SamDrummond opened this issue Aug 27, 2015 · 0 comments
Open

Web Map Reload Scale #7

SamDrummond opened this issue Aug 27, 2015 · 0 comments
Labels

Comments

@SamDrummond
Copy link
Contributor

Why does the web map reload at full scale before zooming to the user defined extent?

A solution that I have used in the past is to modify the extent in the this.appConfig object before recreating the web map

this.own(on(this.themesDijit,
    "selection-change",
    lang.hitch(this, function() {
        this.appConfig.map.itemId = this.themesDijit.getSelected().itemId;

        //change extent in this.appConfig here

        MapManager.getInstance()._recreateMap(this.appConfig);
    })));

Also, I'm a little concerned that this code makes a public call to a private function (denoted by the underscore). Especially when previous snippets that we have sent and examples within the Esri code identify that there are supported methods of updating the web map that involve publishing subscriber events that notify the web app builder that the map is about to change.

/The widget broadcasts a message that the map is about to be destroyed
  topic.publish('beforeMapDestory', this.map);

  //The map is destroyed
  this.map.destroy();

  //A new deffered object is created to handle the creation of a new webmap
  var mapDeferred = jimuUtils.createWebMap(portalUrl, webMapItemId, mapContainerId, webMapOptions);

  //The deffered is executed ensuring that the response is executed with "this" being the widget.js file
  mapDeferred.then(lang.hitch(this, this._processNewMapSuccess), lang.hitch(this, this._processNewMapFail));


//I set up the returned web map as a map object
  var map = response.map;

  map.itemId = this.appConfig.map.itemId;
  map.itemInfo = response.itemInfo;
  map.webMapResponse = response;
  // enable snapping
  var options = {
  snapKey: keys.copyKey
  };

  map.enableSnapping(options);

  //The widget gets a handle on the appConfig
  var appConfig = this.appConfig

  //The map is set as the applications map property
  this.map = map;

  //The widget broadcasts a message that the map has been changed
  //The app builder handles all the magic from here
  topic.publish('mapChanged', this.map);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants