ArcGIS Wpf MarkerSymbol 图形符号无法序列化为 JSON

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ArcGIS Wpf MarkerSymbol 图形符号无法序列化为 JSON相关的知识,希望对你有一定的参考价值。

【问题贴,尚不知如何解决】

 在GraphicsLayer中添加一个点,使用自定义模板渲染该点,在Vs2012设计界面可以看到,但运行时出现异常

代码如下:

 1           <esri:Graphic x:Name="MyGrapic" >
 2             <esri:Graphic.Geometry>
 3               <esri:MapPoint  X="120.198704" Y="35.957860" >
 4                 <esri:MapPoint.SpatialReference>
 5                   <esri:SpatialReference WKID="4326"/>
 6                 </esri:MapPoint.SpatialReference>
 7               </esri:MapPoint>
 8             </esri:Graphic.Geometry>
 9             <esri:Graphic.Symbol>
10               <esri:MarkerSymbol>
11                 <esri:MarkerSymbol.ControlTemplate>
12                   <ControlTemplate>
13                     <Image Source="Images\addvector.png"></Image>
14                   </ControlTemplate>
15                 </esri:MarkerSymbol.ControlTemplate>
16               </esri:MarkerSymbol>
17             </esri:Graphic.Symbol>
18           </esri:Graphic>

异常信息:

未处理System.ArgumentException
HResult=-2147024809
Message=图形符号无法序列化为 JSON
Source=ESRI.ArcGIS.Client
StackTrace:
在 ESRI.ArcGIS.Client.Runtime.NativeGraphicsLayer.GetSymbolJson(Graphic graphic)
在 ESRI.ArcGIS.Client.Runtime.NativeGraphicsLayer.SerializeGraphic(Graphic graphic, Geometry displayGeometry, BinaryWriter output)
在 ESRI.ArcGIS.Client.Runtime.NativeGraphicsLayer.<>c__DisplayClass6.<AddGraphics>b__5(BinaryWriter w)
在 ESRI.ArcGIS.Client.Utils.BinaryWriterExtensions.Write(Action`1 writeAction)
在 ESRI.ArcGIS.Client.Runtime.NativeGraphicsLayer.AddGraphics(IEnumerable`1 graphicGeometryPairs)
在 ESRI.ArcGIS.Client.Runtime.NativeGraphicsLayer.AddGraphics()
在 ESRI.ArcGIS.Client.Runtime.NativeGraphicsLayer.Initialize()
在 ESRI.ArcGIS.Client.NativeMap.AddLayer(Int32 index, Layer layer)
在 ESRI.ArcGIS.Client.DrawingSurface.AddLayer(Int32 index, Layer layer)
在 ESRI.ArcGIS.Client.DrawingSurface.FindIndexAndAddLayer(Layer layer, IList`1 collection)
在 ESRI.ArcGIS.Client.Map.TryAddLayerToDrawSurface(Layer layer)
在 ESRI.ArcGIS.Client.Map.layer_Initialized(Object sender, EventArgs e)
在 System.EventHandler`1.Invoke(Object sender, TEventArgs e)
在 ESRI.ArcGIS.Client.Layer.OnInitialized(EventArgs e)
在 ESRI.ArcGIS.Client.Layer.Initialize()
在 ESRI.ArcGIS.Client.Map.OnApplyTemplate()
在 System.Windows.FrameworkElement.ApplyTemplate()
在 System.Windows.FrameworkElement.MeasureCore(Size availableSize)
在 System.Windows.UIElement.Measure(Size availableSize)
在 System.Windows.Controls.Grid.MeasureOverride(Size constraint)
在 System.Windows.FrameworkElement.MeasureCore(Size availableSize)
在 System.Windows.UIElement.Measure(Size availableSize)
在 System.Windows.Controls.Grid.MeasureOverride(Size constraint)
在 System.Windows.FrameworkElement.MeasureCore(Size availableSize)
在 System.Windows.UIElement.Measure(Size availableSize)
在 MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
在 System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
在 System.Windows.FrameworkElement.MeasureCore(Size availableSize)
在 System.Windows.UIElement.Measure(Size availableSize)
在 System.Windows.Documents.AdornerDecorator.MeasureOverride(Size constraint)
在 System.Windows.FrameworkElement.MeasureCore(Size availableSize)
在 System.Windows.UIElement.Measure(Size availableSize)
在 System.Windows.Controls.Border.MeasureOverride(Size constraint)
在 System.Windows.FrameworkElement.MeasureCore(Size availableSize)
在 System.Windows.UIElement.Measure(Size availableSize)
在 System.Windows.Window.MeasureOverrideHelper(Size constraint)
在 System.Windows.Window.MeasureOverride(Size availableSize)
在 System.Windows.FrameworkElement.MeasureCore(Size availableSize)
在 System.Windows.UIElement.Measure(Size availableSize)
在 System.Windows.Interop.HwndSource.SetLayoutSize()
在 System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value)
在 System.Windows.Window.SetRootVisualAndUpdateSTC()
在 System.Windows.Window.SetupInitialState(Double requestedTop, Double requestedLeft, Double requestedWidth, Double requestedHeight)
在 System.Windows.Window.CreateSourceWindow(Boolean duringShow)
在 System.Windows.Window.ShowHelper(Object booleanBox)
在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
在 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
在 System.Windows.Threading.DispatcherOperation.InvokeImpl()
在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Windows.Threading.DispatcherOperation.Invoke()
在 System.Windows.Threading.Dispatcher.ProcessQueue()
在 System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
在 MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
在 MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
在 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
在 System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
在 MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
在 MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
在 System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
在 System.Windows.Application.RunInternal(Window window)
在 System.Windows.Application.Run()
在 ArcGISWpfApplication1.App.Main() 位置 e:\1-LituGaoke\ProjectCode\2015Projects\ios\IOS\obj\Debug\Application.g.cs:行号 0
在 System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
在 System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
InnerException:

官方Api也是这么写的:

http://resources.arcgis.com/en/help/runtime-wpf/apiref/index.html -  ESRI.ArcGIS.Client.Symbols Namespace : Symbol Class

         <esriSymbols:MarkerSymbol OffsetX="10" OffsetY="10">
              <esriSymbols:MarkerSymbol.ControlTemplate>
                <ControlTemplate>
                  <Border Width="20" Height="20" CornerRadius="3" 
                          BorderBrush="Black" BorderThickness="1" 
                          Background="Blue">
                    <Image Source="myImage.png" />
                  </Border>
                </ControlTemplate>
              </esriSymbols:MarkerSymbol.ControlTemplate>
            </esriSymbols:MarkerSymbol>

 

以上是关于ArcGIS Wpf MarkerSymbol 图形符号无法序列化为 JSON的主要内容,如果未能解决你的问题,请参考以下文章

ArcGIS Runtime SDK for WPF 初始化

关于在WPF应用程序中使用ArcGIS Engine控件的局限性

vs如何显示arcgis 二次开发工具控件

Arcgis Runtime 100.3开发实例源代码调试日志

ESRI ArcGIS:Map.ZoomOut()

arcgis,mapinfo(mapxtreme),openlayers专业GIS系统开发