ThinkGeo.com    |     Documentation    |     Premium Support

Text Layer

Hi Yale, actually am using three layer alreadi,


for map,


bitmap icon


and pie layer.


now i added a text style layer in my design, it throws exception as u cannot add custom style when you use default style. i created tat issue in this sample, can u solve and tell how to show text in below of each icon????


check this cid-08ec3041618e8ee4.skydriv...sample.rar


in that sample u can find two icons in map. i just want to place the label below to each icon.  key = m_Points.Label;// **************************key is the label want to show below in each icon *************************************************


string



Deep, 
  
 Thanks for your post. 
  
 The Custom styles and Default styles can not be used at the same time. You can only use default styles or custom styles at a given scenario. 
  
 Basically the custom styles is targeting for advanced style, for example, ValueStyle, ValueIconStyle etc. I believe there are many topics discussing this topic in the discussion forum. 
  
 Thanks. 
  
 Yale 


Yale 
 Is it possible to add text in value style, if so refer me some example, i will make use of that  
  
 Thanks

Deep, 
  
 I am sorry to say that we did not have any existing samples in our how to I sample showing how to add TextStyles to ValueStyle, while it should be exactly same with other style. 
  
 Following codes show how to use the ValueStyle correctly, the only difference is that when adding ValueItem, just add a corresponding TextStyle instead of a AreaStyle. 
 \HowDoISamples\Styles DrawAFeatureBasedOnAValue 
 \HowDoISamples\Styles\DrawFeaturesBasedOnValues 
 code.thinkgeo.com/projects/show/labelingbasedoncol 
  
 Any more questions just feel free to let me know. 
  
 Thanks. 
  
 Yale 


Yale when am trying to run the sample am getting following exception… 
  
 System.NullReferenceException was unhandled 
   Message="Object reference not set to an instance of an object." 
   Source="DesktopEdition" 
   StackTrace: 
        at ThinkGeo.MapSuite.DesktopEdition.Overlay.Draw(GeoCanvas canvas) 
        at ThinkGeo.MapSuite.DesktopEdition.WpfMap.x03e3d48bcfe7bb6c(IEnumerable`1 xa6f0db4f183189f1) 
        at ThinkGeo.MapSuite.DesktopEdition.WpfMap.xff5b27c00f9678c2(RectangleShape x178b193eec228e6e) 
        at ThinkGeo.MapSuite.DesktopEdition.WpfMap.xe3cee4adb9c72451() 
        at ThinkGeo.MapSuite.DesktopEdition.WpfMap.x9ac8c50f434f4b39(Int32 xb565f4681f05557a) 
        at ThinkGeo.MapSuite.DesktopEdition.WpfMap.Refresh() 
        at CSWpfHowDoISamples.DrawAFeatureBasedOnAValue.DrawAFeatureBasedOnAValue_Loaded(Object sender, RoutedEventArgs e) in C:\Program Files (x86)\ThinkGeo\Map Suite Desktop Evaluation Edition 3.0\Samples\CSharp Wpf How Do I Samples\Styles\DrawAFeatureBasedOnAValue.xaml.cs:line 54 
        at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) 
        at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) 
        at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) 
        at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e) 
        at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent) 
        at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root) 
        at MS.Internal.LoadedOrUnloadedOperation.DoWork() 
        at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks() 
        at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks() 
        at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget) 
        at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget) 
        at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter) 
        at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) 
        at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, 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) 
        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, Boolean isSingleParameter) 
        at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) 
        at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) 
        at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter) 
        at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg) 
        at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) 
        at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) 
        at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) 
        at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame) 
        at System.Windows.Threading.Dispatcher.Run() 
        at System.Windows.Application.RunDispatcher(Object ignore) 
        at System.Windows.Application.RunInternal(Window window) 
        at System.Windows.Application.Run(Window window) 
        at System.Windows.Application.Run() 
        at CS_Wpf_HowDoISamples_For_Debug.App.Main() in C:\Program Files (x86)\ThinkGeo\Map Suite Desktop Evaluation Edition 3.0\Samples\CSharp Wpf How Do I Samples\obj\x86\Debug\App.g.cs:line 0 
        at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) 
        at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) 
        at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 
        at System.Threading.ThreadHelper.ThreadStart_Context(Object state) 
        at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
        at System.Threading.ThreadHelper.ThreadStart() 
   InnerException:  


Deep, 
  
 I am a bit confused with your problem. This exception seems a new problem in your environment? I even did not have a chance to fix your problem reported in the email you sent to me. 
  
 I am curious how and when this problem will happen? I doubt you change some of the code in the HowDoI samples. Can you have a try on some other HowDoI Samples to see if it works or if just create a very simple sample from begging to see if it can display maps. Besides, did you change the data used in this DrawAFeatureBasedOnAValue? 
  
 Any all, this problem seems very wield, and I hope we can get to it soon. 
  
 Thanks. 
  
 Yale 


Yale, 
  I didnt make any changes in your howdoi samples, also i reinstalled and tried it out, the same above exception is thrown in wpfmap1.refresh() method. 
 but yale, i don have much time to see the problem in howdoi samples, so that i sent a mail regarding my issue.can u plz fix that issue so that it can very helpful. so in my sample is there any way to bind the key as label to ploted icons.Is there any possibility to show my requirement in your tool. If so wat the right way to do like that???

Deep, 
  
 Thanks for your reply. 
  
 I am crazy busy recently, I am so sorry not replying your email in a prompt way. I promise to dig into this problem and reply to you via email if you want today. 
  
 Thanks. 
  
 Yale 


Hai Yale  
  
 Sorry  for delay, i sent u a mail regardng a small  issue in text layer. i sent u that working sample, you told that will dig into this problem to solve, but i didnt get any mail, so let me know if u want more details from myside… 
  
 Thanks 
  
 deep

Deep,


I am sorry for the delay, we are recently very busy for the May 1st release and now we are almost on the edge.
 
I think in your sample, your problem is you forget to add the column value which you want to show your text to the features. Try change following code:

if (string.Equals(key, key, StringComparison.InvariantCulture))
{
    feature.ColumnValues.Add("PointType", key);
    feature.ColumnValues.Add("DynamicLabel", "Pie" + "You want to put text here");

    pieMemoryLayer.InternalFeatures.Add("pie" + key, new Feature(BuildPiePolygon(new PointShape(longitude, latitude), 20, 10, 30)));
                    
    // i tried to add the label layer to show label below in each icon.
    //labelLayer.InternalFeatures.Add("pie" + key,new TextStyle("DynamicLabel", "Arial", 10, DrawingFontStyles.Regular, GeoColor.StandardColors.Red, 0, -12));
    labelLayer.InternalFeatures.Add(feature);
 }

 
The screenshot probably will be:

 
Any more questions just feel free to let me know.
 
Thanks.
 
Yale