Need help to create map with bubble markers showing values inside

I'm having trouble creating a sfMap that shows bubble markers in some shapes of my map.

I'm trying to make an map like this

My map is composed by 4 files with the following extensions, .dbf, .prj, .shp, .shx.

In my shp file I don't have access to regions name that I need to separate my data.

Can you help me figure out how to achieve a Map like the one on the attached image?

6 Replies 1 reply marked as answer

RS Ramya Soundar Rajan Syncfusion Team June 29, 2020 12:17 PM UTC

Hi Bruno, 
  
Greetings from Syncfusion. 
  
We have prepared a sample based on your requirement to show bubble marker on map and show the label inside the bubble. You can achieve this requirement by using bubble marker setting of shape file layer and ItemsSource property to accepts the collection values as input.  
 
 
In this sample, the ShapeIDPath property refers the data ID in ItemsSource and the ShapeIDTableField property refers to the column name in the data property of shape layers to identify the shape. The ValuePath represents the field value to be fetched from the data for each bubble. The ShowBubbles property should be enabled for making the bubbles visible and ShowMapItems property should be enabled to show label on bubble marker. 
  
Please refer the code snippet below. 
 
            <maps:SfMaps x:Name="sfmap"> 
                <maps:SfMaps.Layers> 
                    <maps:ShapeFileLayer x:Name="layer" Uri="usa_state.shp" ShapeIDPath="State" ShapeIDTableField="STATE_NAME"  
                                        ShowMapItems="True"  ItemsSource="{Binding Data}"> 
 
                        <maps:ShapeFileLayer.BubbleMarkerSettings> 
                            <maps:BubbleMarkerSetting ShowBubbles="True" ValuePath="Electors" ColorValuePath="Electors" MinSize="20" MaxSize="40"> 
                                <maps:BubbleMarkerSetting.ColorMappings> 
                                    <maps:RangeColorMapping Color="#2E769F" From="0" To="15" /> 
                                    <maps:RangeColorMapping Color="#D84444" To="30" From="15" /> 
                                    <maps:RangeColorMapping Color="#816F28" To="45" From="30" /> 
                                    <maps:RangeColorMapping Color="#7F38A0" To="50" From="45" /> 
                                </maps:BubbleMarkerSetting.ColorMappings> 
                                <maps:BubbleMarkerSetting.TooltipSettings> 
                                    <maps:TooltipSetting ShowTooltip="True" ValuePath="Name" /> 
                                </maps:BubbleMarkerSetting.TooltipSettings> 
                            </maps:BubbleMarkerSetting> 
                        </maps:ShapeFileLayer.BubbleMarkerSettings> 
                        <maps:ShapeFileLayer.ShapeSettings> 
                            <maps:ShapeSetting ShapeFill="LightGray" ShapeValuePath="Electors"/> 
                        </maps:ShapeFileLayer.ShapeSettings> 
                    </maps:ShapeFileLayer> 
                </maps:SfMaps.Layers> 
            </maps:SfMaps> 
 
Please refer the below help document links for more information. 
 
 
Please check with the above sample and let us know if you have any concern 
 
Regards, 
Ramya S 


Marked as answer

BR Bruno July 5, 2020 03:59 PM UTC

Hello there again, I've managed to build a map like I wanted but im having issues on Android.

On iOS maps show fine as supposed.

On Android if I've set bubble marker setting, the app crashes as soon as I open the page.

Can you help me please?

Here's the error:

  at Com.Syncfusion.Maps.BubbleMarkerSetting.FindSizeRatio (System.Object source) [0x00197] in <e4c3a774ebb64b4c9633b0a1783dcb1f>:0 
  at Com.Syncfusion.Maps.ShapeFileLayer.RenderMapElements () [0x000c9] in <e4c3a774ebb64b4c9633b0a1783dcb1f>:0 
  at Com.Syncfusion.Maps.SfMaps.RefreshShapeLayer () [0x000c1] in <e4c3a774ebb64b4c9633b0a1783dcb1f>:0 
  at Com.Syncfusion.Maps.SfMaps.Refresh () [0x00070] in <e4c3a774ebb64b4c9633b0a1783dcb1f>:0 
  at Com.Syncfusion.Maps.ShapeFileLayer.set_DataSource (System.Object value) [0x00061] in <e4c3a774ebb64b4c9633b0a1783dcb1f>:0 
  at Syncfusion.SfMaps.XForms.Droid.ShapeFileLayerMapping.OnShapeFileLayerPropertiesChanged (System.String propertyName, Syncfusion.SfMaps.XForms.ShapeFileLayer formLayer, Com.Syncfusion.Maps.ShapeFileLayer nativeLayer) [0x00043] in <c369d841af6545569a6ef658eed21fd9>:0 
  at Syncfusion.SfMaps.XForms.Droid.ShapeFileLayerMapping.Level_PropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x0001c] in <c369d841af6545569a6ef658eed21fd9>:0 
  at (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
  at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:229 
  at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:353 
  at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00114] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:461 
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:397 
  at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x00214] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:155 
  at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) [0x0003e] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:53 
  at Xamarin.Forms.BindingExpression+BindingExpressionPart.<PropertyChanged>b__49_0 () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:742 
  at Xamarin.Forms.BindingExpression+BindingExpressionPart.PropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs args) [0x000cb] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:753 
  at Xamarin.Forms.BindingExpression+WeakPropertyChangedProxy.OnPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00012] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:646 
  at (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
  at Covid19Tracker.ViewModels.BaseViewModel.OnPropertyChanged (System.String propertyName) [0x00001] in /Users/brunogerardo/Projects/CovidApp/Covid-19Tracker/ViewModels/BaseViewModel.cs:29 
  at Covid19Tracker.ViewModels.PortugalPageViewModel.set_PortugalInfo (Covid19Tracker.Model.PortugalCasesInfo value) [0x00008] in /Users/brunogerardo/Projects/CovidApp/Covid-19Tracker/ViewModels/PortugalPageViewModel.cs:24 
  at Covid19Tracker.ViewModels.PortugalPageViewModel.GetData () [0x0011a] in /Users/brunogerardo/Projects/CovidApp/Covid-19Tracker/ViewModels/PortugalPageViewModel.cs:64 
  at Covid19Tracker.Views.PortugalPage.OnAppearing () [0x00031] in /Users/brunogerardo/Projects/CovidApp/Covid-19Tracker/Views/PortugalPage.xaml.cs:26 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021 
  at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in <55654ebe9f2a48e6bade2862bb243f94>:0 
  at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <55654ebe9f2a48e6bade2862bb243f94>:0 
  at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <55654ebe9f2a48e6bade2862bb243f94>:0 
  at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.1(intptr,intptr)


BR Bruno July 5, 2020 08:08 PM UTC

Now I've set the map to only show when I press a button and the error log is shorter, maybe it can help you 

  at Com.Syncfusion.Maps.BubbleMarkerSetting.FindSizeRatio (System.Object source) [0x00197] in <e4c3a774ebb64b4c9633b0a1783dcb1f>:0 
  at Com.Syncfusion.Maps.ShapeFileLayer.RenderMapElements () [0x000c9] in <e4c3a774ebb64b4c9633b0a1783dcb1f>:0 
  at Com.Syncfusion.Maps.SfMaps.RefreshShapeLayer () [0x000c1] in <e4c3a774ebb64b4c9633b0a1783dcb1f>:0 
  at Com.Syncfusion.Maps.SfMaps.Refresh () [0x00070] in <e4c3a774ebb64b4c9633b0a1783dcb1f>:0 
  at Com.Syncfusion.Maps.SfMaps.OnSizeChanged (System.Int32 w, System.Int32 h, System.Int32 oldw, System.Int32 oldh) [0x003ab] in <e4c3a774ebb64b4c9633b0a1783dcb1f>:0 
  at Android.Views.View.n_OnSizeChanged_IIII (System.IntPtr jnienv, System.IntPtr native__this, System.Int32 w, System.Int32 h, System.Int32 oldw, System.Int32 oldh) [0x00008] in <55654ebe9f2a48e6bade2862bb243f94>:0 
  at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.121(intptr,intptr,int,int,int,int)


SS Sridevi Sivakumar Syncfusion Team July 6, 2020 12:24 PM UTC

Hi Bruno, 
 
We have checked the reported issue based on the stack trace with available testing scenarios. It is working fine at our side. 
 
Can you please share use case and replication scenarios to check at our end and provide a possible solution at earlier? 
 
We would like to let you know that there is a possibility to fix based on the provided stack trace at our end but without knowing the exception details, it is really complex to replicate. Please share us the complete stack trace along with its exception type either Null exception/dispose  exception or any others. 
 
Regards, 
Sridevi S. 



BR Bruno July 6, 2020 03:00 PM UTC

Ok, If there's a way to share my project with you in private, I can send it. This is private project and can't share it publicly.

By now I've set the bubbleMarkerSettings to show only on iOS, but would like to have it on Android too.

Reach to me with a way to share my project with you ASAP then.


HM Hemalatha Marikumar Syncfusion Team July 7, 2020 07:24 AM UTC

Hi Bruno, 
 
Thanks for your update.  
 
You can mail your complete application to our support mailbox [email protected]. We will keep your application as confidential. 
 
Please also share the exception details along with what type of exception. 
 
Regards,
Hemalatha M. 


Loader.
Up arrow icon