Select to view content in your preferred language

Restrict LODs for Tiled service

1417
5
11-16-2010 12:00 PM
DaveTimmins
Deactivated User
Hi,

I'm wanting to control the amount that a user can zoom in for a tiled service, the reason is that some other data is being overlayed but I don't want users to see the physical address associated which they can if they zoom in far enough.

Setting the MinimumResolution on the layer or all layers just stops them drawing instead of stopping the zoom. Also there is no way to cancel an extent change event.

I've also tried to remove some LODs from the Tiled service which does stop the tile images from updating but the user can still zoom in and the images are resampled (not nice). I tried SnapToLevels but it didn't make a difference.

Currently the best hack I've found is to do this

void MapExtentChanging(object sender, ExtentEventArgs e)
        {
            var newResolution = (e.NewExtent.Extent.Width / Map.ActualWidth);
           
            if (newResolution < 5)
                Map.Extent = e.OldExtent.Extent;
        }

but the UX isn't great as there's a bit of a jutter still when trying to zoom in.

Any ideas how to do this better? I know I could have another service with the correct LODs but that isn't possible in this instance.

Regards,
0 Kudos
5 Replies
JenniferNery
Esri Regular Contributor
Check ZoomToResolution from this page: http://help.arcgis.com/en/webapi/silverlight/help/Navigating_map.htm

After the tiled layer has initialized, you will have TileInfo, Lods and their respective resolution. You can pick the desired Lod.Resolution and use this for comparison with Map.Resolution on Map.ExtentChanging event.

Alternatively, if you already know the extent for the desired Lod.Resolution you can add ConstrainExtentBehavior http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#ConstrainExtentBehavior
0 Kudos
DaveTimmins
Deactivated User
Hi Jennifer,

thanks for your suggestions. Both those options give a simliar UX to what I was currently trying so I don't think I can really implement these for the final solution. Would be nice if you could manually override the LOD collection and have it propagated through to the Map or even nicer, have a Max / Min Resolution property on the Map. Sure you can squeeze that into 2.1 final 🙂

Cheers,
0 Kudos
DaveTimmins
Deactivated User
OK, I got it to do what I want but it's not pretty.

I call this after the map layers have initialised so internally the map has set it's min / max resolution.

var tiledLayer = new ArcGISTiledMapServiceLayer{ Url=@"http://services.arcgisonline.co.nz/ArcGIS/rest/services/Generic/newzealand/MapServer" };
                        tiledLayer.Initialized += (s, a) =>
                                          {
                                              var layer = s as ArcGISTiledMapServiceLayer;
                                              if (layer == null)
                                                  return;

                                              layer.TileInfo.Lods =
                                                  layer.TileInfo.Lods.Take(layer.TileInfo.Lods.Count() - 3).ToArray();
                                          };

            Map.Layers.Insert(0, tiledLayer);

This means that the LODs is now correct in the navigation control but as I said, pretty hacky.

Cheers,
0 Kudos
DaveTimmins
Deactivated User
LOL! How did I miss that. Must have been suffering from brain fade.

Maybe it would make sense though for the map to set it's Max / Min Resolution based on the values for it's Layers if not set explicitly.

Anyway, that does what I want, thanks for your help.

Cheers,
0 Kudos