void CrossGeolocator_Current_PositionChanged(object sender, PositionEventArgs e)
 {
     Device.BeginInvokeOnMainThread(() =>
     {
         var position = e.Position;
         Positions.Add(position);
         count++;
         LabelCount.Text    = $"{count} updates";
         labelGPSTrack.Text = string.Format("Time: {0} \nLat: {1} \nLong: {2} \nAltitude: {3} \nAltitude Accuracy: {4} \nAccuracy: {5} \nHeading: {6} \nSpeed: {7}",
                                            position.Timestamp, position.Latitude, position.Longitude,
                                            position.Altitude, position.AltitudeAccuracy, position.Accuracy, position.Heading, position.Speed);
         speed.Text = String.Format("{0:F2}", position.Speed);
         MyMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Xamarin.Forms.Maps.Position(position.Latitude, position.Longitude), Distance.FromMiles(1)));
     });
 }
Exemplo n.º 2
0
        public Page1()
        {
            InitializeComponent();

            var map = new Map(MapSpan.FromCenterAndRadius(new Position(37.5758422, 126.971386), Distance.FromMiles(0.2)))
            {
                IsShowingUser   = true,
                MapType         = MapType.Street,
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            var pin = new Pin
            {
                Type     = PinType.Place,
                Position = new Position(37.5758422, 126.971386),
                Label    = "위치",
                Address  = "주소"
            };

            map.Pins.Add(pin);

            var slider = new Slider(1, 18, 1);

            slider.ValueChanged += (s, e) => {
                var zoomLevel      = e.NewValue;
                var latlongdegrees = 360 / (Math.Pow(2, zoomLevel));
                map.MoveToRegion(new MapSpan(map.VisibleRegion.Center, latlongdegrees, latlongdegrees));
            };

            Content = new StackLayout
            {
                Children = { map, slider }
            };
        }