What I'm trying to accomplish is to update collections of MyAnnotations
already added in MapView:

Dictionary<long, MyAnnotation> _annotations;

private void OnUpdate(Dictionary<uint, MyObject> updatedObjects)
{
    // Add or Update annotations on map
    foreach (var pair in updatedObjects)
    {
        uint id = pair.Key;
        MyObject obj = pair.Value;

        double lat = obj.Latitude;
        double lon = obj.Longitude;

        if (_annotations.ContainsKey(key)) // Update existing objects
        {
            _annotations[id].Coordinate = new CLLocationCoordinate2D(lat, lon);
            _annotations[id].Obj = obj;
        }
        else // Add new object to map
        {
            var annotation = new MyAnnotation(new
CLLocationCoordinate2D(lat, lon), obj);
            _annotations.Add(id, annotation);
            InvokeOnMainThread(() => MapView.AddAnnotation(annotation));
        }
    }
}


but annotations does not get updates!!!

Does MapView receive KVO notifications automaticly when
MKAnnotation.Coordinate property has been changed and what is the
AddAnnotationObject methode for?

Falowed by this
thread<http://monotouch.2284126.n4.nabble.com/setCoordinate-binding-td3799997.html>
 (
http://monotouch.2284126.n4.nabble.com/setCoordinate-binding-td3799997.html)
made my annotation (but not help - annotation did not change coordinates):

        protected class MapAnnotation : MKAnnotation
        {
            private CLLocationCoordinate2D _coordinate;

            public MapAnnotation(CLLocationCoordinate2D coordinate,
MyObject obj)
            {
                _coordinate = coordinate;
                Obj = obj;
            }

            public override sealed CLLocationCoordinate2D Coordinate
            {
                get { return _coordinate; }
                set
                {
                    WillChangeValue("coordinate"); // supose to triger
MapView KVO
                    _coordinate = value;
                    DidChangeValue("coordinate"); // supose to triger
MapView KVO
                }
            }

            public override string Title
            {
                get { return Obj.MyTitle; }
            }

            public override string Subtitle
            {
                get { return Obj.MySubtitle; }
            }

            public Object Obj { get; set; }
        }
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to