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

Update map annotations

Hi!

In my application I show some coordinates on the map as annotations to the main ShapeLayer. The map shows them correctly, but at runtime, the list of annotations may change depending on user input. But whilst the list of annotation changes, the circles shown on the map do not. How can I make the map update when its viewmodel changes?

This is my annotation type:

    public class ConnectionAnnotation : Annotation
    {
        public ConnectionViewModel Connection { get; set; }
        public Countries Country { get; set; }

        public ConnectionAnnotation(ConnectionViewModel connection,
            DbGeography location, Countries country)
        {
            Connection = connection;
            Longitude = location.Longitude ?? 0;
            Latitude = location.Latitude ?? 0;
            Country = country;
        }
    }

The map is bound to an ObservableCollection<Annotation> yet it does not change when the annotation list changes.

            shapeLayer.Annotations = viewModel.AnnotationList;

            newMapsControl1.AnnotationDrawing += mapsControl_AnnotationDrawing;

            newMapsControl1.Layers.Add(shapeLayer);

So can you please help me update / refresh the map?
I tried 

            this.mapsControl.UpdateLayers();

but it did not work!


Best wishes!

1 Reply

AK Ashwin Kumaravel Syncfusion Team June 23, 2017 06:55 AM UTC

Hi MS,

Thank you for using Syncfusion products,

We have validated your query, could you please call Refresh method along with UpdateLayers to refresh the map elements?

Please refer the following code snippet for your references,

     mapsControl1.UpdateLayers();
     mapsControl1.Refresh();


Please get back us if you have any concern.

Regards,
Ashwin.k


Loader.
Live Chat Icon For mobile
Up arrow icon