AnsweredAssumed Answered

Capture attribute values from a WebMap without click event

Question asked by lalver1 on Nov 10, 2017
Latest reply on Nov 22, 2017 by rscheitlin

I have a general question about how to capture attribute values from a WebMap (using API 4.x) without using click events on the map (this thread #Capture attribute values from a WebMap has an excellent solution using the click event and the hitTest method, but now I need to access attribute values without having to click on the map).

This thread #Access ArcGIS Server database content from JavaScript application has a solution based on QueryTask (API 3.22), but I don't know what this object maps to in API 4.4.

I am also not aware of having access to a REST service associated with this WebMap, and I am not familiar with the ArcGIS framework, but if I have access to a WebMap through the portalItem property, does that mean that I should get access to a REST service too? Is there a way I can access the attribute values without setting up a REST service?

I would also like to avoid using the FeatureLayer object since my web application resides in a different domain than the ArcGIS server and when I try to use FeatureLayer I get a CORS error.

I apologize for the vagueness but thanks for your help,



I am also a bit confused why 

console.log("Num WebMap Layers: "+webmap.layers.length);

displays zero for number of WebMap layers, I guess they are embedded differently into the WebMap?


My current code:

], function(MapView, WebMap) {
* Creates a new WebMap instance. A WebMap must reference
* a PortalItem ID that represents a WebMap saved to
* or an on-premise portal.

var webmap = new WebMap({
portalItem: { // autocasts as new PortalItem()
id: "7faf8d05df114f8082411414382c69d3"
//id: "65de4dd5bbfb4c0dbac85d395052bee3" // Speed Studies Web Map
* Set the WebMap instance to the map property in a MapView.

var view = new MapView({
map: webmap,
container: "viewMap"
view.on("click", function(event) {