Select to view content in your preferred language

Add mapservice without AGOL/map itemId

992
8
05-01-2018 09:44 AM
MonaBrisco
Occasional Contributor

All,

Where would I add mapservice/featurelayer urls to load on startup in WAB Developer Edition 2.5/2.7?  I've tried to alter the MapManager.js/utils.js files(_show2DWebMap, _createWebMapRaw, createWebMap) but I assume it needs the portal Url, webmapid, etc..  I can manually place an id(from AGOL) in the config after creating an app and create a custom widget that when clicked can load the layers onto the map.  However, I would like by default when I create apps in WAB Dev Ed to load my custom basemap without using a map id from AGOL.  Also, for specific apps I need layers loaded onto that map(layers vary).  I have done this using JS API 3.x but would like to incorporate into WAB.  Any ideas?  Thanks in advance!

0 Kudos
8 Replies
RobertScheitlin__GISP
MVP Emeritus

Mona,

   This is exactly what the Local Layer widget was created for.

GitHub - cmndrbensisko/LocalLayer at v2.5 

MonaBrisco
Occasional Contributor

Hi Robert,

First thanks for letting me know this was out there.  Secondly, I could not get this to work.  I placed in stemapp/widgets folder and edit the config to renamed widget.  I've started/restarted several times and cannot get the widget to show amongst other widgets.  Third, as I think about it I am not sure that this is going to work as I do not want the user to click on the widget to execute the code.  So in the completed app the user on launch of the app would see the basemap and layers automatically without clicking on a widget.  Any suggestions?  If I could get the widget you are suggesting to work...is there a way to execute it on app launch?  Thanks in advance!

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Mona,

   You do not see the Local Layer widget in the normal list of widget and you do not click on it to get the widget to add the layers to the map. It is a panelless widget that runs at startup to add layers to the map automatically. There is documentation on how to setup and Rebecca's blog on how to get it working in the link I provided.

0 Kudos
MonaBrisco
Occasional Contributor

Robert,

Thanks for clearing things up...and I read the other posts...I now see the widget amongst the others where I can now configure it to add layers or basemaps.  However, the basemap I have in the parent config file for the widget does not load.  I see in the dev tools that it needs my spatial reference for my basemap(instead of the default).  How/where do I add my spatial reference?  Do I place in config as "spatialReference": mySpatialReference,?  Thanks!

0 Kudos
MonaBrisco
Occasional Contributor

Robert,

I added my spatial reference in JSON format but no luck.  I also looked at the files and saw that the SR for my area is in the wkid list.  I tried to also enter the URL in the Edit Basemap Layers and I get the error "Different spatial reference with current map" since the map on launch is still the ESRI topo map/default.  Any other ideas?  I will start from the beginning again and see if I still have the same results.  Thanks in advance.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Mona,

   So you are going down a path that I am not sure you should be on. So explain to me your situation. Are you wanting to use a custom basemap that is not in WKID 102100? and your data is also not in 102100?

0 Kudos
MonaBrisco
Occasional Contributor

Robert,

Yes, that is correct.  I tried adding a standard basemap from AGOL(after reading content from another link) and then configured the widget to add other maps and no luck...adding a featurelayer did not help either.  I tried both public and private services.  I tried adding the services just in the config as I do not necessarily need to use the GUI in development for this part.  Is what I want to do possible?  I thought it was as simple as removing the map info in the config and adding the js code as in JS API 3.x...but guess not.  If I remove the itemId, map options, and portal info from the config file then the default map still displays but just at a different map extent.  Thanks for your help.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Mona,

   You don't need to be messing with the main config.json manually at all if you use the Local Layer widget. You should start from scratch (new app). Use the LocalLayer widget, and remove all the pre-configured layers from the widget UI. Add your basemap that uses a WKID other then 102100 and then add the other layers you want to add that are in the same wkid. That's it.

0 Kudos