private void NativeMapOnMyLocationChange(object sender, GoogleMap.MyLocationChangeEventArgs e)
        {
            if (e?.Location == null)
            {
                return;
            }

            if (Element is ResearchMap researchMap)
            {
                if (researchMap.CameraFollowsUser)
                {
                    var newLat  = e.Location.Latitude;
                    var newLong = e.Location.Longitude;
                    var bearing = e.Location.Bearing;

                    var cameraPositionBuilder = CameraPosition.InvokeBuilder();
                    cameraPositionBuilder.Target(new LatLng(newLat, newLong));
                    cameraPositionBuilder.Bearing(bearing);
                    cameraPositionBuilder.Zoom(researchMap.CameraZoom);

                    var cameraPosition = cameraPositionBuilder.Build();
                    var cameraUpdate   = CameraUpdateFactory.NewCameraPosition(cameraPosition);

                    NativeMap.AnimateCamera(cameraUpdate);
                }
            }

            // Console.WriteLine($"ResearchMapRenderer: Lat={location.Latitude}, Long={location.Longitude}, Alt={location.Altitude}, Spd={location.Speed}, Acc={location.Accuracy}, Hdg={location.Bearing}");
        }
예제 #2
0
        /// <summary>
        /// Quick function to animate the camera to a location
        /// on the map.
        /// </summary>
        /// <param name="lat">Latitude to move to.</param>
        /// <param name="lon">Longitude to move to.</param>
        /// <param name="zoom">Level to zoom to over 100ms.</param>
        public void AnimateCameraTo(double lat, double lon, float zoom = 0)
        {
            try
            {
                if (zoom == 0)
                {
                    zoom = KCApi.Properties.Renderer.NativeMap.CameraPosition.Zoom;
                }

                Device.BeginInvokeOnMainThread(() =>
                {
                    if (KCApi.Properties.MapReady && KCApi.Properties.RenderReady && NativeMap != null)
                    {
                        lock (nativeMapLock)
                        {
                            NativeMap.AnimateCamera(CameraUpdateFactory.NewLatLngZoom(new LatLng(lat, lon), zoom), 100, null);
                        }
                    }
                });
            }
            catch (Exception e)
            {
                KCApi.OutputException(e);
            }
        }
예제 #3
0
        private void ShowRouteOverview()
        {
            NativeMap.Clear();

            PolylineOptions selectedRoutePolyline = new PolylineOptions();

            selectedRoutePolyline.InvokeColor(Resource.Color.colorPrimaryDark);
            selectedRoutePolyline.InvokeWidth(20f);

            LatLng[] allRoutePoints = _xamap.SelectedRoute.Legs
                                      .SelectMany(leg => leg.Points)
                                      .Select(point => new LatLng(point.Latitude, point.Longitude))
                                      .ToArray();

            selectedRoutePolyline.Add(allRoutePoints);
            NativeMap.AddPolyline(selectedRoutePolyline);

            LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
            LatLngBounds         routeBounds   = allRoutePoints
                                                 .Aggregate(boundsBuilder, (builder, latLng) => builder.Include(latLng))
                                                 .Build();

            CameraUpdate routeOverviewMapUpdate = CameraUpdateFactory.NewLatLngBounds(routeBounds, 50);

            NativeMap.AnimateCamera(routeOverviewMapUpdate);
        }
예제 #4
0
        public void OnMapClick(LatLng point)
        {
            NativeMap.AnimateCamera(CameraUpdateFactory.NewLatLng(point));
            var marker = new MarkerOptions();

            marker.SetPosition(new LatLng(point.Latitude, point.Longitude));
            marker.SetTitle("New Title");
            marker.SetSnippet("Latitude:" + point.Latitude + " Longitude:" + point.Latitude);
            marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.pin));
            NativeMap.AddMarker(marker);

            NativeMap.Clear();
            var pin = new CustomPin
            {
                Pin = new Pin
                {
                    Type     = PinType.Place,
                    Position = new Position(point.Latitude, point.Longitude),
                    Label    = "Xamarin San Francisco Office",
                    Address  = "394 Pacific Ave, San Francisco CA"
                },
                Id  = "Xamarin",
                Url = "http://xamarin.com/about/"
            };

            customPins.Add(pin);
            //cMap.an
            // map.animateCamera(CameraUpdateFactory.newLatLng(arg0));
            // NewCameraPosition
        }
예제 #5
0
 public void AnimateCamera(CameraUpdate cameraUpdate)
 {
     if (cameraUpdate != null)
     {
         NativeMap?.AnimateCamera(cameraUpdate);
     }
 }
예제 #6
0
        private void UpdateDriverLocation()
        {
            LatLng         currentPosition = new LatLng(_xamap.CurrentLocation.Latitude, _xamap.CurrentLocation.Longitude);
            CameraPosition newPosition     = new CameraPosition(
                currentPosition, 18, NativeMap.CameraPosition.Tilt, (float)_xamap.Bearing);

            CameraUpdate rotationUpdate = CameraUpdateFactory.NewCameraPosition(newPosition);

            NativeMap.AnimateCamera(rotationUpdate, 200, null);
        }
        private void Map_MarkerClick(object sender, GoogleMap.MarkerClickEventArgs e)
        {
            var mapTile = (MapTile)Element;

            mapTile.SelectedPinId = e.Marker.Snippet;

            if (!string.IsNullOrEmpty(mapTile.SelectedPinId))
            {
                var camera = CameraUpdateFactory.NewLatLng(e.Marker.Position);
                NativeMap.AnimateCamera(camera, 200, null);
            }
        }
예제 #8
0
        private void LocationChange(object sender, GoogleMap.MyLocationChangeEventArgs e)
        {
            if (IsMoving)
            {
                return;
            }
            else
            {
                IsMoving = true;
            }
            CameraPosition cameraPosition = new CameraPosition(target: new LatLng(e.Location.Latitude, e.Location.Longitude), zoom: 20f, tilt: 45f, bearing: e.Location.Bearing);
            CameraUpdate   cameraUpdate   = CameraUpdateFactory.NewCameraPosition(cameraPosition);

            NativeMap.AnimateCamera(cameraUpdate);
        }
예제 #9
0
        void Map_MarkerClick(object sender, GoogleMap.MarkerClickEventArgs e)
        {
            var marker  = e.Marker;
            var mapTile = (MapTile)Element;

            var newCamera    = CameraUpdateFactory.NewLatLng(marker.Position);
            var moveCallBack = new MoveCallback();

            moveCallBack.Finishing += (ss, ee) =>
            {
                if (marker.Snippet != CurrentLocationSnippet)
                {
                    mapTile.ShowPinDetailInfo(marker.Snippet);
                }
            };
            NativeMap.AnimateCamera(newCamera, 200, moveCallBack);
        }