Esri / application-boilerplate-3x-js

Starter application that simplifies the process of building templates for the ArcGIS.com template gallery.
https://developers.arcgis.com/javascript/
Apache License 2.0
90 stars 68 forks source link

4.x: Provide defaultMap for webmap and webscene supporting apps #99

Closed alaframboise closed 7 years ago

alaframboise commented 7 years ago

The new boilerplate supports both webmaps and webscenes. Either of these can be missing params and it would be good to have a simple fallback mechanism if you just hit the template end-point and just wants the default map. e.g.

http://myserver/mytemplate/index.html

This is a bit tricky however for templates that support both 2D and 3D. What map do you give back?

Maybe we should do something like this:

http://myserver/mytemplate/index.html?webmap=default

http://myserver/mytemplate/index.html?webscene=default

While we are here, we should probably trap for the edge case when both are passed in.

http://myserver/mytemplate/index.html?webscene=xxx&webmap=xxx

@driskull

driskull commented 7 years ago

Installed

alaframboise commented 7 years ago

Verified fixed.

alaframboise commented 7 years ago

Spoke too soon. If you have both defaults set in settings.json, the logic will always default to webmap. Need a bit more logic to let it default to either or.

This works:

{
  "localConfig": {
    "fetch": true
  },
  "defaultWebmap": "df5b4bad631d4209b6ef7a88493dac7d",
  "defaultWebscene": "a5ef8bf91d234aaa93ea61e7ddf0bdf5",
  "defaultGroup": "",
...
}
      if (!this.config.webmap && !this.config.webscene) {
        if (this.settings.defaultWebmap) {
          this.config.webmap = this.settings.defaultWebmap;
        } else if (this.settings.defaultWebscene) {
          this.config.webscene = this.settings.defaultWebscene;
        }
      } else if (this.config.webmap === DEFAULT_URL_PARAM && this.settings.defaultWebmap) {
        this.config.webmap = this.settings.defaultWebmap;
      } else if (this.config.webscene === DEFAULT_URL_PARAM  && this.settings.defaultWebscene) {
        this.config.webscene = this.settings.defaultWebscene;
      }
      if ((!this.config.group || this.config.group === DEFAULT_URL_PARAM) && this.settings.defaultGroup) {
        this.config.group = this.settings.defaultGroup;
      }
driskull commented 7 years ago

I think you'll just need to change the logic here: https://github.com/Esri/application-boilerplate-js/blob/4master/js/application/app.js#L95

Shouldn't be an issue though.

driskull commented 7 years ago

Should be fine. That logic is only in the app, not the boilerplate