Map control based on Xamarin.Forms.Maps.Map
상속: Xamarin.Forms.Maps.Map
예제 #1
0
        private void BindToElement(Map map)
        {
            if (map != null)
            {
                NativeMap.CameraChange += NativeMap_CameraChange;
                NativeMap.MarkerClick += NativeMap_MarkerClick;
                map.PinsInternal.CollectionChanged += OnPinsCollectionChanged;
                map.PolylinesInternal.CollectionChanged += OnPolylinesCollectionChanged;
                MessagingCenter.Subscribe<XamMapz.Map, MapMessage>(this, MapMessage.Message, (sender, message) =>
                    {
                        // Handle only messages sent by Element
                        if (sender != MapEx)
                            return;

                        OnMapMessage(sender, message);
                    });
            }
        }
예제 #2
0
 private void UnbindFromElement(Map map)
 {
     if (map != null)
     {
         MessagingCenter.Unsubscribe<Map, MapMessage>(this, MapMessage.Message);
         NativeMap.CameraChange -= NativeMap_CameraChange;
         NativeMap.MarkerClick -= NativeMap_MarkerClick;
         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;
         }
     }
 }
예제 #3
0
        protected virtual void OnMapMessage(Map map, MapMessage message)
        {
            if (message is ZoomMessage)
            {
                //var msg = (ZoomMessage)message;
                UpdateRegion();
            }
            else if (message is ProjectionMessage)
            {
                var msg = (ProjectionMessage)message;
                var screenPos = NativeMap.Projection.ToScreenLocation(msg.Position.ToLatLng());
                msg.ScreenPosition = new Point(screenPos.X, screenPos.Y);
            }
            else if (message is MoveMessage)
            {
                var msg = (MoveMessage)message;
                UpdateGoogleMap(formsMap =>
                    {
                        var cameraUpdate = CameraUpdateFactory.NewLatLng(msg.Target.ToLatLng());
                        NativeMap.MoveCamera(cameraUpdate);
                    });

            }
        }