Select to view content in your preferred language

scale dependant feature layers?

2513
2
07-07-2011 01:56 PM
TerryGiles
Frequent Contributor
I have a map service w/ 2 layers in it both with a min & max scale set.  If I add the service as an ArcGISDynamicMapServiceLayer to a map, these scale dependancies are honored even in the Legend control.

If I just want to add one of the layers from that MapService as a FeatureLayer to a map, how would I do it using the values that I can see in the MapService Layer?  The Layer class has a minResolution and maxResolution but is that the same as scale? 

partial code snippet of how I create the FeatureLayer -
                                //mapservice is a class returned from an EntityQuery that pulls service properties from a database
                                FLayer = new FeatureLayer();
                                FLayer.Url = mapservice.ServerURL + "/" + mapservice.MapServiceName;
                                FLayer.Mode = FeatureLayer.QueryMode.OnDemand;
                                FLayer.Initialized += FLayer_Initialized;
                                if (mapservice.Proxy)
                                {
                                    FLayer.ProxyUrl = "../proxy.ashx";
                                }
                                layer = FLayer;
....snip...
                layer.InitializationFailed += Layer_InitializationFailed;
                layer.ID = mapservice.DisplayName;
                layer.Opacity = mapservice.Transparency == 0 ? 100 : 1 - (Convert.ToDouble(mapservice.Transparency) / 100);
                layer.Visible = mapservice.Active;

                MyMap.Layers.Add(layer);



Do I need to get the min/max scales using something like
WebClient Web = new WebClient();
Web.DownloadStringAsynch(Flayer.url + "?f=pjson");

And grab the scale properties from the json layer description?


Thanks, Terry
0 Kudos
2 Replies
JenniferNery
Esri Regular Contributor
MinimumScale and MaximumScale values in FeatureLayer.LayerInfo are internal. This is a related thread: http://forums.arcgis.com/threads/10296-Using-MINSCALE-defined-in-ArcMap

MinimumResolution and MaximumResolution also determines visibility of the layer: http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.Layer~Mini... but they are not the same values as MinimumScale and MaximumScale. They are however related. You can look at the doc re: Map Scale and Resolution here. http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.Map.html
0 Kudos
MichaelBlom
Deactivated User
A few comments.

stepping throught the silverlight toolkit code, I can see that the legend template's IsInScaleRange is based on MaxResolution and MinResolution properties from my layer, which do not relate at all to the scale thresholds I've set in my mxd....  this seems odd that IsInScaleRange is not based on Scale value.

so, from what I've read, the way to get my feature layer to honour it's max min scale values from the mxd is:
1.  after the layer has initialzed (layer_Initialized), make another http request to get the json, and retrieve the minscale maxscale values from this.
2.  calcuate what the maxResolution and minResolution values should be based on max/min Scale values.
3.  set the max/min Resolution values.

It would be great if for a featureLayer the max min Scale properties were exposed (as they are for an ArcGISDynamicMapService), and then for the IsInScaleRange (in the legend template) to actually use these max/min Scale ranges (taken from the mxd) rather than the seemingly irrelevent max and min Resolution.

Mike
0 Kudos