Querying a Layer using an ArcGIS Online Map

ArcGIS-OnlineWhile exploring the possibilities of ArcGIS API for JavaScript, I was wondering how to query a web map that has been created through ArcGIS Online.

I spent quite a lot of time trying to figure out how to pass my Web Map created through ArcGIS Online as a URL. Especially for “var MapServiceToDisplay” and “var MapServiceToSearch”.

So here is the answer:

The first thing you have to do is create an account in ArcGIS Online. After catering for profile photos and other general settings, create a map.


Next you have to Share this new map


After that, add an item to your map, preferably from your computer


Remember also to Publish this file as a feature layer


Next: Share this Feature Layer


Next step is to Add Feature Layer to Map, Save your map after adding your layer.


Now, as soon as you do that, if you click on the Map that this new layer resides, you will get the following link for the Map Contents:


You can now use this link for var MapServiceToDisplay and var MapServiceToSearch whenever you want to refer to this map as follows:

var MapServiceToDisplay = “https://services5.arcgis.com/3a3dkCUNh3aCnKgy/ArcGIS/rest/services/kalyvia_egsa/FeatureServer/”;
var MapServiceToSearch = “https://services5.arcgis.com/3a3dkCUNh3aCnKgy/ArcGIS/rest/services/kalyvia_egsa/FeatureServer/0”;

0 in the line above implies the layer you want to query.

Leave a comment

Your email address will not be published. Required fields are marked *