Error when I customize Marker on Maps

Hello,

I used OSM as layer provider. When I used my own image to customize the marker I get this error:

<< Java.Lang.NullPointerException: 'Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference' >>



XAML Code:

<maps:SfMaps x:Name="MapsTier">

        <maps:SfMaps.Layers>

            <maps:ImageryLayer x:Name="MapLayerTier" LayerType="OSM"/>

        </maps:SfMaps.Layers>

    </maps:SfMaps>


C# Code:

//MapsTier

            foreach (var tier in listElements)

            {

                if ((tier.Latitude == null) || (tier.Longitude == null) || ((tier.Latitude == 0) && (tier.Longitude == 0)))

                    continue;

                MapMarker marker = new MapMarker();

                marker.Label = tier.Nom + "\n" + tier.Solde.ToString("N2");

                marker.Latitude = tier.Latitude.ToString();

                marker.Longitude = tier.Longitude.ToString();

                MapLayerTier.Markers.Add(marker);

            }

            MapMarkerSetting markerSetting = new MapMarkerSetting();

            markerSetting.MarkerIcon = MapMarkerIcon.Image;

            markerSetting.ImageSource = "MarkerTier.png";

            markerSetting.IconSize = 48;

            markerSetting.LabelSize = 20;

            MapLayerTier.MarkerSettings = markerSetting;


Best regards


 


2 Replies

CO Cosyspro May 9, 2022 11:34 AM UTC

Hi,

I observed that this problem occurs when I use an Icon with black backgroundcolor.

Regards



ET Eswaran Thirugnanasambandam Syncfusion Team May 9, 2022 03:34 PM UTC

We prepared a sample with the provided code snippet and checked the reported problem “Error when I customize Marker on Maps”. But we are unable to reproduce the problem in our side and in our sample we used the back background image. Please get the tested sample from the below attachment.


If you still face any problem, please revert us by modifying the sample based on your application scenario along with the replication steps. This will allow us to assist you with a better solution as soon as possible.


Attachment: XamarinMaps_d686f4a4.zip

Loader.
Up arrow icon