ThinkGeo.com    |     Documentation    |     Premium Support

"text-align" in StyleJSON for MBTiles causes crash

If I specify any value for “text-align” as described in https://wiki.thinkgeo.com/wiki/thinkgeo_stylejson I get the following exception:-

Unhandled Exception: Newtonsoft.Json.JsonSerializationException: Error converting value “left” to type ‘System.Nullable`1[QBU=.PxU=]’. Path ‘styles[1].style[8].text-align’, line 195, position 25. —> System.ArgumentException: Requested value ‘left’ was not found.
at Newtonsoft.Json.Utilities.EnumUtils.ParseEnum(Type enumType, NamingStrategy namingStrategy, String value, Boolean disallowNumber)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)
— End of inner exception stack trace —
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)
at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType)
at Newtonsoft.Json.Linq.JToken.ToObjectT
at ThinkGeo.MapSuite.Layers.ThinkGeoMBTilesFeatureLayer.5hc=(StyleJsonDocument styleJsonDocument)
at ThinkGeo.MapSuite.Layers.ThinkGeoMBTilesFeatureLayer.OpenCore()
at ThinkGeo.MapSuite.Layers.Layer.Open()
at ThinkGeoMBTilesMapsSample_ForWpf.MainWindow.Window_Loaded(Object sender, RoutedEventArgs e) in D:\builds\RandD\ThinkGeoMBTilesMapsSample-ForWpf-master\OrdnanceSurveyZoomstack\MainWindow.xaml.cs:line 66
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
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.Interop.HwndTarget.OnResize()
at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(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 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)

Hi John,

Thanks to let us know it, our developer is look into this issue, any question or update I will let you know.

Regards,

Ethan

Hi John,

We should had fixed that, please upgrade your packages to latest prerelease version.

Regards,

Ethan

Hi Ethan

I no longer get the exception with the updated packages. However, if I set the “text-align” property to ‘left’, ‘right’ or ‘center’ this has no effect on the text alignment when drawn. Also, if I set the property to ‘end’ or ‘start’ I get an exception.

I am following the documentation for StyleJSON from this page. Which says the following with regard to “text-align” :-

      Description: Sets the alignment of text. Default Value: `center` Available Values: `left` `right` `center` `end` `start`.

Packages updated to the following:-

Thanks
John

Packages are as follows:-

MapSuiteDependency-GeoAPI v10.5.0
MapSuiteDependency-MicrosoftSqlServerTypes v10.5.0
MapSuiteDependency-MicrosoftVisualCRunTime100 v10.5.1
MapSuiteDependency-NetTopologySuite v10.5.0
MapSuiteDependency-NewtonsoftJson v10.5.0
MapSuiteDependency-SkiaSharp v10.5.0
MapSuiteDependency-SQLiteCore v10.5.0
MapSuiteDesktopForWpf-BareBone v11.0.0
ThinkGeo.Cloud.Client v11.0.0
ThinkGeo.MapSuite v11.0.0
ThinkGeo.MapSuite.Layers.ThinkGeoMBTiles v11.0.0
ThinkGeo.MapSuite.ProductCenter v11.0.0

Hi John,

I need double check about end and start with our development team.

In fact our class only contains center, left and right for now.

I will update this post when I get reply.

Regards,

Ethan

Hi John,

I get reply from our development team, that should be an error message in wiki page, this type only support left right and center.

Regards,

Ethan