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(); } } }
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; } }
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(); } }
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; }
public TestPage() { Content = new XamMapz.Map(); }