<esri:ArcGISDynamicMapServiceLayer x:Uid="dynMapSvcId" ID="BigMap" Url="" />
<esri:ArcGISDynamicMapServiceLayer x:Uid="dynMapSvcId" ID="BigMap" Url="http://<server>/ArcGIS/rest/services/<mapService>" />
<esri:ArcGISDynamicMapServiceLayer x:Uid="dynMapSvcId" ID="BigMap" Url="http://<server>/ArcGIS/rest/services/<mapService>" Initialized="BigMap_Initialized" />
<esri:ArcGISDynamicMapServiceLayer x:Uid="dynMapSvcId" ID="BigMap" Url="" />
My understanding is that you know the url of your map service, so it should be:<esri:ArcGISDynamicMapServiceLayer x:Uid="dynMapSvcId" ID="BigMap" Url="http://<server>/ArcGIS/rest/services/<mapService>" />
then you can add an Initialized event handler:<esri:ArcGISDynamicMapServiceLayer x:Uid="dynMapSvcId" ID="BigMap" Url="http://<server>/ArcGIS/rest/services/<mapService>" Initialized="BigMap_Initialized" />
and in the event handler you can use the LayerInfo array to define which layerID you want to work with and make your query.
Note that instead of using a graphicslayer and a query, you could use a feature layer which is basically doing that without any code from you. You just have to initialize the Url of the feature layer which is also something like http://<server>/ArcGIS/rest/services/<mapService>/LayerID
Hi,
something like this?
int GetLayerID(string layerName)
{
var client = new WebClient();
client.DownloadStringCompleted += (sender, args) =>
{
string json = args.Result;
foreach (var layer in JObject.Parse(json)["layers"].Children())
{
if (string.Equals((string)layer["name"], layerName, StringComparison.OrdinalIgnoreCase))
return (int)layer["id"];
}
throw new InvalidOperationException(string.Format("A layer with the name '{0}' was not found in the MXD.", layerName));
};
string uri = "your map server url" + "?f=json";
client.DownloadStringAsync(new Uri(uri));
}
Hi,
something like this?
int GetLayerID(string layerName)
{
var client = new WebClient();
client.DownloadStringCompleted += (sender, args) =>
{
string json = args.Result;
foreach (var layer in JObject.Parse(json)["layers"].Children())
{
if (string.Equals((string)layer["name"], layerName, StringComparison.OrdinalIgnoreCase))
return (int)layer["id"];
}
throw new InvalidOperationException(string.Format("A layer with the name '{0}' was not found in the MXD.", layerName));
};
string uri = "your map server url" + "?f=json";
client.DownloadStringAsync(new Uri(uri));
}