Example #1
0
        public void OnMapMessage(Map sender, XamMapz.Messaging.MapMessage message)
        {
            if (message is ZoomMessage)
            {
//                var msg = (ZoomMessage)message;
                if (_mapViewDelegate.IsRegionChanging == false)
                {
                    UpdateRegion();
                }
            }
            else if (message is ProjectionMessage)
            {
                var msg       = (ProjectionMessage)message;
                var screenPos = MKMapPoint.FromCoordinate(msg.Position.ToCoordinate2D());
                msg.ScreenPosition = new Point(screenPos.X, screenPos.Y);
            }
            else if (message is MoveMessage)
            {
                if (_mapViewDelegate.IsRegionChanging == false)
                {
                    var msg = (MoveMessage)message;
                    NativeMap.CenterCoordinate = msg.Target.ToCoordinate2D();
                }
            }
        }
Example #2
0
 private void Bind(Map map)
 {
     try
     {
         _renderHelper.BindToElement(map);
         // overwriting existing delegate throws exception, so set it to null first
         NativeMap.Delegate = null;
         NativeMap.Delegate = _mapViewDelegate;
     }
     catch (Exception ex)
     {
         var x = ex;
     }
 }
Example #3
0
        public void BindToElement(Map map)
        {
            if (map != null)
            {
                _map = map;
                map.PinsInternal.CollectionChanged      += OnPinsCollectionChanged;
                map.PolylinesInternal.CollectionChanged += OnPolylinesCollectionChanged;
                MessagingCenter.Subscribe <XamMapz.Map, MapMessage>(this, MapMessage.Message, (map1, message) =>
                {
                    // Handle only messages sent by the current map instance
                    if (map1 != _map)
                    {
                        return;
                    }

                    _renderer.OnMapMessage(map1, message);
                });
                UpdatePins();
                UpdatePolylines();
            }
        }
Example #4
0
        public void UnbindFromElement()
        {
            if (_map == null)
            {
                return;
            }

            MessagingCenter.Unsubscribe <Map, MapMessage>(this, MapMessage.Message);
            _map.PinsInternal.CollectionChanged      -= OnPinsCollectionChanged;
            _map.PolylinesInternal.CollectionChanged -= OnPolylinesCollectionChanged;
            foreach (var polyline in _map.Polylines)
            {
                polyline.PositionChanged -= polyline_PositionChanged;
                polyline.PropertyChanged -= polyline_PropertyChanged;
            }
            foreach (var pin in _map.Pins)
            {
                pin.PropertyChanged -= pin_PropertyChanged;
            }
            _dict.Clear();
            _map = null;
        }
Example #5
0
 public TestPage()
 {
     Content = new XamMapz.Map();
 }
Example #6
0
 public TestPage()
 {
     Content = new XamMapz.Map();
 }