Exemplo n.º 1
0
        public MapPage()
        {
            var customMap = new CustomMap
            {
                MapType = MapType.Street,
                WidthRequest = App.ScreenWidth,
                HeightRequest = App.ScreenHeight
            };

            geoCoder = new Geocoder ();

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

            locator.GetPositionAsync (timeoutMilliseconds: 10000).ContinueWith (t => {

                var pin = new CustomPin {
                    Pin = new Pin {
                        Type = PinType.Place,
                        Position = new Xamarin.Forms.Maps.Position (t.Result.Latitude, t.Result.Longitude),
                        Label = "Ma Position",
                        //Address = "394 Pacific Ave, San Francisco CA"
                    },
                    Name = "Xam",
                    Id = "Xamarin"
                };

                customMap.CustomPins = new List<CustomPin> { pin };
                customMap.Pins.Add (pin.Pin);
                customMap.MoveToRegion (MapSpan.FromCenterAndRadius (new Xamarin.Forms.Maps.Position (t.Result.Latitude, t.Result.Longitude), Distance.FromMiles (0.3)));

                Content = customMap;
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }