I am using ArcGIS online to create a web map and then I want to query this web map using ArcGIS API for JavaScript. In the tutorials I read I see

var queryTask = new QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5");

But I want to use my own web map which is "http://pawebgate.maps.arcgis.com/home/webmap/viewer.html?webmap=a0c647159b46456b963d8b180e062b57"

I have tried using the whole http://... it did not work. I have tried using only a0c647159b46456b963d8b180e062b57 it did not work.

Has anyone got any idea about how to use my web map instead of the http://samplserver1 ...

  • I think that after quite a big research, I can integrate an ArcGIS Online map with ArcGIS for JavaScript, but I can not query it. It must come from ArcGIS Server, let me know if I am correct!
    – pancy1
    Commented Jun 7, 2015 at 19:14

1 Answer 1


Webmaps are not synonymous with ArcGIS Server (or even ArcGIS Online) feature services because a webmap is typically composed of a collection/mashup of a variety of different data sources.

this doesn't mean you can't query layers from a webmap. it just means that as a developer you have to get a reference to the particular layer of interest out of the JSAPI map object itself instead of writing in your own hardcoded urls.

one way of doing this is to make a call to map.getLayer('yourlayerid'); https://developers.arcgis.com/javascript/jsapi/map-amd.html#getlayer


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.