Example #1
0
        public App()
        {
            App.Self = this;

            var locator = CrossGeolocator.Current;
            locator.DesiredAccuracy = 50;

            var position = locator.GetPositionAsync(timeoutMilliseconds: 10000).ContinueWith((t) =>
            {
                if (t.IsCompleted)
                {
                    if (MyPosition == null)
                        MyPosition = new LatLong(t.Result.Latitude, t.Result.Longitude);
                }
            }).ConfigureAwait(true);

            PositionChanged += (object sender, PositionEventArgs e) =>
            {
                MyPosition.UpdatePosition(e.Position.Latitude, e.Position.Longitude);
                MessagingCenter.Send<App>(this, "LocChange");
            };

            PositionError += (object sender, PositionErrorEventArgs e) =>
            {
                MessagingCenter.Send<App, string>(this, "LocError", e.Error.ToString());
            };

            MainPage = new NavigationPage(new MappingPage());
        }
Example #2
0
        void SaveLocation()
        {
            var location = new LatLong(map.VisibleRegion.Center.Latitude, map.VisibleRegion.Center.Longitude);

            // save the location to the internal settings
        }
Example #3
0
 void MoveMapTo(LatLong location)
 {
     map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(location.Latitude, location.Longitude), DefaultMapDistance));
 }