We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Binding observable collection of custom markers

Thread ID:

Created:

Updated:

Platform:

Replies:

142101 Jan 18,2019 06:45 PM UTC Jan 21,2019 06:41 AM UTC Xamarin.Forms 2
loading
Tags: SfMaps
Rjuken Developments
Asked On January 18, 2019 06:50 PM UTC

Hello syncfusion team,

I'm trying to bind a collection of custom markers to the Markers property of the SfMaps.

But it throws me an error :

 Binding: System.Collections.ObjectModel.ObservableCollection`1[Project.Core.Models.WeatherMarker] can not be converted to type 'System.Collections.ObjectModel.ObservableCollection`1[Syncfusion.SfMaps.XForms.MapMarker]' 
Well, I don't understand because using  the same marker class but w/o binding works. Is it bindable ? 

Marker class is pretty simple : 

   public class WeatherMarker : MapMarker
    {
        public string LottieAnimation { get; set; }
    }


    private ObservableCollection _weatherMarkers;
        public ObservableCollection WeatherMarkers
        {
            get => _weatherMarkers;
            set => SetProperty(ref _weatherMarkers, value);
        }


 < maps:SfMaps  x:Name="sfmap" EnablePanning="False" EnableZooming="False" BackgroundColor="Transparent" >
                < maps:SfMaps.Layers >
                    < maps:ShapeFileLayer x:Name="ShapeLayer" Uri="FRA_adm0.shp" MarkerTemplate="{Binding MarkerDataTemplate}" Markers="{Binding WeatherMarkers}" >
                        < maps:ShapeFileLayer.ShapeSettings >
                            < maps:ShapeSetting  ShapeFill="{StaticResource PrimaryColorOne}" ShapeStroke="white" ShapeStrokeThickness="2" >
                            < /maps:ShapeSetting >
                        < /maps:ShapeFileLayer.ShapeSettings >
                    < /maps:ShapeFileLayer >
                < /maps:SfMaps.Layers >
            < /maps:SfMaps >


Regards. 


Rjuken Developments
Replied On January 18, 2019 07:15 PM UTC

Okay so I found out what's going on.

I have to type my ObservableCollection to MapMarker and not WeatherMarker.  

    private ObservableCollection< MapMarker > _weatherMarkers;
        public ObservableCollection< MapMarker > WeatherMarkers
        {
            get => _weatherMarkers;
            set => SetProperty(ref _weatherMarkers, value);
        }

Instead of : 

    private ObservableCollection< WeatherMarker > _weatherMarkers;
        public ObservableCollection< WeatherMarker > WeatherMarkers
        {
            get => _weatherMarkers;
            set => SetProperty(ref _weatherMarkers, value);
        }

It should work with WeatherMarker as it derives from MapMarker. Anyway, working now. 

Padmini Ramamurthy [Syncfusion]
Replied On January 21, 2019 06:41 AM UTC

Hi Rjuken Developments, 
  
Glad that you have resolved the issue and please get back to us anytime if you need any other assistance. 
  
Regards, 
Padmini R. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;