Select to view content in your preferred language

Using MINSCALE defined in ArcMap

2686
7
08-12-2010 03:23 PM
StephenLead
Honored Contributor
When I look in my REST Services catalog, I can see that a MINSCALE has been defined for a layer:

Min. Scale: 250000

How can I use this value in Silverlight, without having to hard-code it? That is, I want this layer in Silverlight to use whatever value for MINSCALE was set using ArcMap.

Thanks,
Steve
0 Kudos
7 Replies
JenniferNery
Esri Regular Contributor
Currently, MinimumScale is an internal property in the FeatureLayer.LayerInfo, so you will not be able to access it at this time.

Jennifer
0 Kudos
StephenLead
Honored Contributor
Thanks Jennifer.

If there isn't one already, can you please open an enhancement request for this functionality? It would seem to be a logical extension of the new ability to use ArcMap symbology in ArcGIS Server.

Steve
0 Kudos
JenniferNery
Esri Regular Contributor
Sure, I will make sure to forward that request to our Dev Lead.

Jennifer
0 Kudos
StephenLead
Honored Contributor
Hi Jennifer,

Next question, which I should have asked earlier - how do I set the MINSCALE manually? You mentioned layerinfo, but I can only see visibility, ID, name and sublayerids on this class.

Using this simple example, how would I specify the min and max scale range?

<esri:FeatureLayer ID="MyFeatureLayer" Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/Map..." />

(Or is that what you mean about it being an internal property - it's not possible to set a minscale at all?)

Thanks,
Steve
0 Kudos
JenniferNery
Esri Regular Contributor
Hi Steve,

Why would you need to set the MinimumScale? Our current API has does not update this internal property. It is only used as metadata information. So if you have a use case for needing this property exposed and editable, please let us know.

Even though this property is currently internal to our API, there's nothing stopping you from retrieving this information from the json string.

You can do a call to DownloadStringAsync from WebClient, with Uri = layer's url appended with "?f=json". In the DownloadStringCompleted eventhandler, you can parse the result to get MinimumScale property.
0 Kudos
StephenLead
Honored Contributor
Why would you need to set the MinimumScale?


To rephrase the question, I don't want the features to draw when I zoom out beyond the Min Scale.

At the moment they draw at all scales, and even with clustering this isn't ideal. I'd like them to switch off when I zoom out beyond 1:250k (or whatever is set in ArcGIS Server).

What's the best way to achieve this?

You can do a call to DownloadStringAsync from WebClient, with Uri = layer's url appended with "?f=json". In the DownloadStringCompleted eventhandler, you can parse the result to get MinimumScale property.


Can you point me to some sample code for this?

Thanks again for your help,
Steve
0 Kudos
JenniferNery
Esri Regular Contributor
I don't want the features to draw when I zoom out beyond the Min Scale.

This might be something we will support out-of-the-box in the future versions of our API.

But for the meantime, you can get the minimum scale information from your layer this way.
        public MainPage()
        {
            InitializeComponent();
            FeatureLayer layer = this.MyMap.Layers["LayerID"] as FeatureLayer;
            if (layer == null) return;
            WebClient webClient = new WebClient();
            webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadStringCompleted);
            webClient.DownloadStringAsync(new Uri(layer.Url + "?f=json", UriKind.RelativeOrAbsolute));
        }

        void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            string[] properties = e.Result.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            string minScale = properties.FirstOrDefault(p => p.Contains("minScale"));
            if(minScale != null)
                minScale = minScale.Substring(minScale.IndexOf(':') + 1, minScale.Length - (minScale.IndexOf(':') +1));            
//TODO: use this minScale value.
        }
0 Kudos