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. Image for the cookie policy date

Updating the Shape Layer Item Source and refreshing Map

Hello!
I am building a WinForms app which makes use of the Maps control. My data source is a list of countries defined as:
public class CountryViewModel : INotifyPropertyChanged
    {
        private int selected;
        public int Selected
        {
            get
            { return selected; }
            set
            { selected = value; NotifyPropertyChanged("Selected"); }
        }

        # region Implementing INotifyPropertyChanged
        public event PropertyChangedEventHandler PropertyChanged;

        private void NotifyPropertyChanged(String info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }

I have used the one ShapeLayer to load the map of the world  and furthermore I have added a ColorMapping such that Countries with Selected = 1 show in a different colour.

My map also allows selection. What I wish to do is to colour the countries I have selected with a ColorMapping.
What I have done is that when catching the ShapeSelected event of the map I update the ViewModel such that the selected country will have the Selected value toggled to one. Then to my understanding all I need to do is refresh the data source, and the ColorMapping should color these newly selected countries as I wish.
I have tried to refresh the map, to update the data source, to add another ShapeLayer with this updated data source, and nothing worked. 
How can I now refresh the data source of the map at runtime such that I can colour or uncolour the countries I have selected or deselected?

Thank you kindly for all your help,

3 Replies

AK Ashwin Kumaravel Syncfusion Team May 30, 2017 07:18 AM UTC

Hi MS,

Thanks for using Syncfusion products,

We have validated your query and created a sample based on your requirement in which we have coloured the selected shape using colourMapping. Whenever new shape is selected its get updated in the ViewModel and the selected shape is rendered with different colors using EqualColorMapping.

Please find the sample from the below link, 
Sample-MapsSample

Screenshot- 

Please get back to us if you have any concern

Regards,
Ashwin.k
 



MS MS June 14, 2017 04:04 PM UTC

Thank you, this was very helpful!


AK Ashwin Kumaravel Syncfusion Team June 15, 2017 10:22 AM UTC

Hi MS,

We are glad to know that you have met your requirement. Please let us know if you have any queries.

Regards,
Ashwin.k


Loader.
Up arrow icon