예제 #1
0
        private void UserLocationSubscription(Location location)
        {
            if (location == lastLocation)
            {
                return;
            }
            lastLocation = location;

            Position position = new Position(location.Latitude, location.Longitude);

            if (formsMap.Pins.Any())
            {
                formsMap.Pins[0].Position = position;
            }
            else
            {
                formsMap.Pins.Add(new Pin {
                    Position = position, Label = "UserLocation", Type = PinType.Generic
                });
            }

            if (userAnnotationView != null)
            {
                userAnnotationView.Transform = CGAffineTransform.MakeRotation((float)UnitConverters.DegreesToRadians(lastLocation?.Course ?? 0));
            }

            //formsMap.MoveToRegion(MapSpan.FromCenterAndRadius(position, Distance.FromKilometers(1)));
            nativeMap.SetRegion(MKCoordinateRegion.FromDistance(new CLLocationCoordinate2D(position.Latitude, position.Longitude), 1000, 1000), false);
        }
예제 #2
0
 private MarkerOptions CreateUserMarker()
 {
     userMarkerOptions = new MarkerOptions();
     userMarkerOptions.SetPosition(new LatLng(lastLocation?.Latitude ?? 30, lastLocation?.Longitude ?? 30));
     userMarkerOptions.SetTitle("UserPostion");
     userMarkerOptions.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.icono));
     userMarkerOptions.SetRotation((float)UnitConverters.DegreesToRadians(lastLocation?.Course ?? 0));
     return(userMarkerOptions);
 }
 public void DegreesToRadians(double deg, double rad)
 {
     Assert.Equal(rad, UnitConverters.DegreesToRadians(deg), 4);
 }