Does anyone know how to consume REST services within Web app builder that are not included within the Web Map

4096
5
07-28-2016 11:43 AM
AntoineBartholomew
New Contributor III

Does anyone know how to consume REST services within Web app builder, that are not added into the initially created web map.  I want to be able to work with (consume) services without linking the service into the web map.  

If I want to add a REST URL into my map, without adding the REST service into a Web Map (1st); can I use the FeaturelayerServiceBrowser class to accomplish this?  https://developers.arcgis.com/web-appbuilder/api-reference/featurelayerservicebrowser.htm

How can I add data layers to the Web APP without first adding the layer into a web map?  Can I directly pull JSON (GeoJSON?) data into the web map like this:

http://www.geothread.net/importing-geojson-data-in-arcgis-javascript-maps/

https://community.esri.com/thread/17970

All I can find is the link below that says this type of work flow is not supported.

  https://blogs.esri.com/esri/arcgis/2015/04/06/clarifying-3-questions-about-web-appbuilder-for-arcgis...

0 Kudos
5 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Antoine,

  In WAB 2.1 there is an add data widget

Add Data widget—Web AppBuilder for ArcGIS (Developer Edition) | ArcGIS for Developers

There is also some custom widgets like the LocalLayer widget

LocalLayerWidget and AccessifizrWidget

and

AddLayer Widget 

and

Add Service Widget 1.2

But no matter what you have to have a WebMap to start with and then the above widgets allow you to add additional services

AntoineBartholomew
New Contributor III

Thanks for the reply Robert

I want to clarify what you said; your saying the only two work flows that are supported by web app builder are:

1. add services within a web map, that is referenced by the web app builder application or

2. add services into interactions with the widgets themselves.

There is not a way to add services (a layer) within the web app builder JavaScript code, that same way you would add a layer programmatically like: 

require([
   "esri/Map",
   "esri/views/SceneView",
   "esri/layers/TileLayer"// Require the TileLayer module
   "dojo/domReady!"
  ],
  function(
  Map, SceneView, TileLayer
 
)
{

   var transportationLyr = new TileLayer({
  url: "https://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Transportation/MapServer"
  });

   var housingLyr = new TileLayer({
  url: "https://tiles.arcgis.com/tiles/nGt4QxSblgDfeJn9/arcgis/rest/services/New_York_Housing_Density/MapSer..."
  });
});

Get started with layers | ArcGIS API for JavaScript 4.0

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Antoine,

No you can add layers by code just as the custom widgets do, but there is no configuration that allows you to specify a certain map service in a json file that the WAB stemApp automatically reads and just adds to the map for you.

GirishYadav
Occasional Contributor

Hi Antoine,

Yes, you can add any layer (that is supported by ArcGIS JS API) to the Map object in WAB app the same way you do it using ArcGIS JS API.

If you want to add layer into the map at app startup then put your code in the widget that is configured as  "WidgetOnScreen". and put your code to add layer in widget's postCreate or startup function. (can also specify the layer url in the widgets config). Every widget inherited from "jimu/BaseWidget" does have reference to the map object. You can simply add any layer into this.

To make REST service requests from the WAB use "esri.request" or "dojo/request" or any other JS request handler.

Thanks,

Girish

AntoineBartholomew
New Contributor III

I found that you have to add each service URL individually as an Operational Layer -> http://resources.arcgis.com/en/help/arcgis-web-map-json/#/operationalLayer/02qt00000006000000/

Then once the layers are showing overtop of the base map, create the pop-up -> http://resources.arcgis.com/en/help/arcgis-web-map-json/#/popupInfo/02qt00000008000000/

0 Kudos