zoukankan      html  css  js  c++  java
  • 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="Imagesaddvector.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-LituGaokeProjectCode2015ProjectsIOSIOSobjDebugApplication.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>

     有遇到了另一个问题,使用<esri:PictureMarkerSymbol.ControlTemplate>自定义PictureMarkerSymbol,报出“不支持所指定方法”,异常信息如下:

    未处理System.NotSupportedException
      HResult=-2146233067
      Message=不支持所指定的方法。
      Source=ESRI.ArcGIS.Client
      StackTrace:
           在 ESRI.ArcGIS.Client.Symbols.PictureMarkerSymbol.ToJsonInternal(Boolean nativeMapSerialization)
           在 ESRI.ArcGIS.Client.Symbols.PictureMarkerSymbol.ESRI.ArcGIS.Client.IJsonSerializableNativeDisplay.ToNativeDisplayJson()
           在 ESRI.ArcGIS.Client.JsonSerializableExtensions.SerializeToJson(Object o, Boolean nativeDisplay)
           在 ESRI.ArcGIS.Client.SimpleRenderer.ToJsonInternal(Boolean nativeDisplay)
           在 ESRI.ArcGIS.Client.SimpleRenderer.ESRI.ArcGIS.Client.IJsonSerializableNativeDisplay.ToNativeDisplayJson()
           在 ESRI.ArcGIS.Client.JsonSerializableExtensions.SerializeToJson(Object o, Boolean nativeDisplay)
           在 ESRI.ArcGIS.Client.Runtime.NativeGraphicsLayer.UpdateRenderer()
           在 ESRI.ArcGIS.Client.Runtime.NativeGraphicsLayer.OnPropertyChanged(String propertyName)
           在 ESRI.ArcGIS.Client.Runtime.NativeLayer.layer_PropertyChanged(Object sender, PropertyChangedEventArgs e)
           在 System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
           在 ESRI.ArcGIS.Client.Layer.OnPropertyChanged(String propertyName)
           在 ESRI.ArcGIS.Client.GraphicsLayer.set_Renderer(IRenderer value)
           在 IOS.MainWindow.LbxFuntion_OnSelectionChanged(Object sender, SelectionChangedEventArgs e) 位置 e:1-LituGaokeProjectCode2015ProjectsIOSIOSMainWindow.xaml.cs:行号 334
           在 System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
           在 System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
           在 System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
           在 System.Windows.Controls.ListBox.OnSelectionChanged(SelectionChangedEventArgs e)
           在 System.Windows.Controls.Primitives.Selector.SelectionChanger.End()
           在 System.Windows.Controls.Primitives.Selector.SetSelectedHelper(Object item, FrameworkElement UI, Boolean selected)
           在 System.Windows.Controls.Primitives.Selector.NotifyIsSelectedChanged(FrameworkElement container, Boolean selected, RoutedEventArgs e)
           在 System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
           在 System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
           在 System.Windows.Controls.ListBoxItem.OnSelected(RoutedEventArgs e)
           在 System.Windows.Controls.ListBoxItem.OnIsSelectedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
           在 System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
           在 System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
           在 System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
           在 System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
           在 System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
           在 System.Windows.DependencyObject.SetCurrentValueInternal(DependencyProperty dp, Object value)
           在 System.Windows.Controls.ListBox.NotifyListItemClicked(ListBoxItem item, MouseButton mouseButton)
           在 System.Windows.Controls.ListBoxItem.OnMouseLeftButtonDown(MouseButtonEventArgs e)
           在 System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
           在 System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
           在 System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
           在 System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
           在 System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
           在 System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
           在 System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
           在 System.Windows.Input.InputManager.ProcessStagingArea()
           在 System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
           在 System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
           在 System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
           在 System.Windows.Interop.HwndSource.InputFilterMessage(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-LituGaokeProjectCode2015ProjectsIOSIOSobjDebugApplication.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: 
  • 相关阅读:
    方向ajax(http long request实现实时通信)
    HTTP防盗链与反防盗链
    linux开启过程详解
    自动化运维工具----saltstack安装及配置
    python----网络编程(TCP通讯)
    windows----bat方式实现ftp推送
    shell----ftp推送
    python----FTP文件拉取(new)
    haproxy----四层负载均衡
    python----时间转换
  • 原文地址:https://www.cnblogs.com/yutian/p/5216362.html
Copyright © 2011-2022 走看看