Is it possible to set extent for a service in to WebApp Builder based on its service login credentials?

551
2
10-17-2017 06:47 AM
by Anonymous User
Not applicable

Question - Is it possible to set the extent for a service in a WebApp Builder site, based on its service login credentials?

So we have a secured service from 10.2.2 in a WAB 2.5 site. It would be neat to have it zoom to a specific extent based on multiple different logins to the service.  So each user would see a different extent after logging in. I am using the secured service to 'password' the site. So for one city to log in they'd see imagery and the extent in their city. And for another city, they'd log in, and it'd show this second city's extent. And so forth. Would this require some kind of Server Object Extension, Python, other backend work? Possible via REST API?  I am not sure where to begin and happy to research or review documentation but it's such a simple yet outside the box user request I had I am wondering how to approach it.  Thanks all!

0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus

Kevin,

  Sure it is possible I did a test by adding a secure service and then this code to the MapManager.js

(line 13 and 19 - 24):

...
      constructor: function( /*Object*/ options, mapDivId) {
        this.appConfig = options.appConfig;
        this.urlParams = options.urlParams;
        this.mapDivId = mapDivId;
        this.id = mapDivId;
        this.appStateManager = AppStateManager.getInstance(this.urlParams);
        this.popupManager = PopupManager.getInstance(this);
        this.filterManager = FilterManager.getInstance();
        this.nls = window.jimuNls;
        topic.subscribe("appConfigChanged", lang.hitch(this, this.onAppConfigChanged));
        topic.subscribe("syncExtent", lang.hitch(this, this.onSyncExtent));
        topic.subscribe('anyUserSignIn', lang.hitch(this, this._onUserSignIn));

        on(window, 'resize', lang.hitch(this, this.onWindowResize));
        on(window, 'beforeunload', lang.hitch(this, this.onBeforeUnload));
      },

      _onUserSignIn: function(credential){
        console.info(credential);
        if(credential.userId === "rscheitlin"){
          this.map.setExtent(new Extent({"xmin":-122.68,"ymin":45.53,"xmax":-122.45,"ymax":45.6,"spatialReference":{"wkid":4326}}));
        }
      },
...
by Anonymous User
Not applicable

Great. I was thinking about this and realized I was coming at it from the backend (which would be a nice permanent edition to the API) but doing it programmatically making it change extent would work. I was thinking I'd use ID manager (IdentityManager | API Reference | ArcGIS API for JavaScript 3.22 ) and set it based on who ID manager says is logged in just as in your example. I was just looking at your thread in fact: Has anyone built a login widget?   This looks like exactly what I was thinking Robert thanks and I'll test it out.

0 Kudos