Select to view content in your preferred language

how to update overviewmap layer

875
4
01-23-2011 02:10 PM
ThaoNguyen
Emerging Contributor
Is it true that, one cannot specify a map layer for the attribute Url of ArcGISTiledMapServiceLayer (or Dynamice layer) of an OverviewMap ?

For instance, the sample has something like below:

<esri:OverviewMap x:Name="MyOverviewMap"
                                  Margin="8,0,0,8"
                                  MaximumExtent="-41381301,-19971868,41381301,19971868"
                                  Map="{Binding ElementName=MyMap}">
                    <esri:OverviewMap.Layer>
                        <esri:ArcGISTiledMapServiceLayer ID="StreetLayer"
                            Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
                    </esri:OverviewMap.Layer>
                </esri:OverviewMap>

I want to update the Url to include the layer id (.../MapServer/30) and it failed.  Wonder if this is not supported?  Our map is changed to different layers when navigating and I want the overview map to reflect the new layer when the main map is changed. Is there a way to do that?

Thanks!
0 Kudos
4 Replies
JenniferNery
Esri Regular Contributor
What error message do you get?

ArcGISTiledMapServiceLayer URL property can be updated programmatically as shown in this sample: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#SwitchMap. However, note that these 3 map service share the same SpatialReference.
0 Kudos
ThaoNguyen
Emerging Contributor
What error message do you get? 

ArcGISTiledMapServiceLayer URL property can be updated programmatically as shown in this sample:   http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#SwitchMap. However, note that these 3 map service share the same SpatialReference.


I guess I was not clear. I want to change the layer ID in the URL attribute. My overview map has only 1 dynamic layer and when my map layer ID is changed, I want to update the URL attribute of the overview map. It is not arcgis layer, it is the map layer. All of my map layers have the same spatial reference. When I specify layer ID in the URL (e.g. http://myMachine/arcgis/rest/services/ContinentalUS/MapServer/2), I get the following exception. I guess including layer ID to the URL is not supported. When I remove the ID, everything works.

{System.NullReferenceException: Object reference not set to an instance of an object.
at ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer.MapServiceInfoInitialized(Object sender, MapServiceInitalizeArgs args)
at ESRI.ArcGIS.Client.Services.MapService.OnInitialized(MapServiceInitalizeArgs args)
at ESRI.ArcGIS.Client.Services.MapService.wc_DownloadStringCompleted(Object sender, DownloadStringCompletedEventArgs e)
at System.Net.WebClient.OnDownloadStringCompleted(DownloadStringCompletedEventArgs e)
at System.Net.WebClient.DownloadStringOperationCompleted(Object arg)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
0 Kudos
dotMorten_esri
Esri Notable Contributor
You cannot pick individual layers from a cached service.
If you want to only show a specific sublayer, you should use the ArcGISDynamicMapServiceLayer instead and set the VisibleIds to int[] { 30 }.
0 Kudos
ThaoNguyen
Emerging Contributor
You cannot pick individual layers from a cached service.
If you want to only show a specific sublayer, you should use the ArcGISDynamicMapServiceLayer instead and set the VisibleIds to int[] { 30 }.


Oh yeah, didn't think about setting visible layers.  I already use ArcGISDynamicMapServiceLayer.  I guess you meant VisibleLayers (this method is available for esri 9 and 10).  This answers my question.  Thanks!
0 Kudos