当前位置: 首页>>代码示例>>C#>>正文


C# Map.MoveToRegion方法代码示例

本文整理汇总了C#中Map.MoveToRegion方法的典型用法代码示例。如果您正苦于以下问题:C# Map.MoveToRegion方法的具体用法?C# Map.MoveToRegion怎么用?C# Map.MoveToRegion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Map的用法示例。


在下文中一共展示了Map.MoveToRegion方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LamanPin

        public LamanPin ()
        {
            peta = new Map
            {
                IsShowingUser = true,
                HeightRequest = 100,
                WidthRequest = 960,
                VerticalOptions = LayoutOptions.CenterAndExpand
            };

            peta.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(-6.1949718, 106.8208304), Distance.FromKilometers(1)));
            var posisi = new Position(-6.1949718, 106.8208304);
            var pin = new Pin
            {
                Type = PinType.Place,
                Position = posisi,
                Label = "Hotel Indonesia",
                Address = "apa ya?"
            };

            peta.Pins.Add(pin);

            var pinLagi = new Button {Text = "Pin Lagi."};
            pinLagi.Clicked += (sender, e) =>
            {
                peta.Pins.Add(new Pin
                {
                    Position = new Position(-6.2279962, 106.6528529),
                    Label = "Jalan NN no 75."
                });
                peta.Pins.Add(new Pin
                {
                    Position = new Position(-6.2266733, 106.6554782),
                    Label = "Jalan Haji Jali."
                });
                peta.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(-6.2257428, 106.6548106),
                    Distance.FromKilometers(2)));
            };

            var balikLagi = new Button {Text = "Kembali Ke HI."};
            balikLagi.Clicked += (sender, e) =>
            {
                peta.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(-6.1949718, 106.8208304), Distance.FromKilometers(2)));
            };

            var butts = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Children = {pinLagi, balikLagi}
            };

            Content = new StackLayout
            {
                Spacing = 0,
                Children = {peta, butts}
            };
        }
开发者ID:ibnuda,项目名称:WatIsDis,代码行数:57,代码来源:LamanPin.cs

示例2: PinPage

		public PinPage ()
		{
			map = new Map { 
				IsShowingUser = true,
				HeightRequest = 100,
				WidthRequest = 960,
				VerticalOptions = LayoutOptions.FillAndExpand
			};

			map.MoveToRegion (MapSpan.FromCenterAndRadius (
				new Position (36.9628066,-122.0194722), Distance.FromMiles (3))); // Santa Cruz golf course

			var position = new Position(36.9628066,-122.0194722); // Latitude, Longitude
			var pin = new Pin {
				Type = PinType.Place,
				Position = position,
				Label = "Santa Cruz",
				Address = "custom detail info"
			};
			map.Pins.Add(pin);


			// create buttons
			var morePins = new Button { Text = "Add more pins" };
			morePins.Clicked += (sender, e) => {
				map.Pins.Add(new Pin {
					Position = new Position(36.9641949,-122.0177232),
					Label = "Boardwalk"
				});
				map.Pins.Add(new Pin {
					Position = new Position(36.9571571,-122.0173544),
					Label = "Wharf"
				});
				map.MoveToRegion (MapSpan.FromCenterAndRadius (
					new Position (36.9628066,-122.0194722), Distance.FromMiles (1.5)));

			};
			var reLocate = new Button { Text = "Re-center" };
			reLocate.Clicked += (sender, e) => {
				map.MoveToRegion (MapSpan.FromCenterAndRadius (
					new Position (36.9628066,-122.0194722), Distance.FromMiles (3)));
			};
			var buttons = new StackLayout {
				Orientation = StackOrientation.Horizontal,
				Children = {
					morePins, reLocate
				}
			};

			// put the page together
			Content = new StackLayout { 
				Spacing = 0,
				Children = {
					map,
					buttons
				}};
		}
开发者ID:89sos98,项目名称:xamarin-forms-samples,代码行数:57,代码来源:PinPage.cs

示例3: MapPage

		public MapPage ()
		{
			map = new Map { 
				IsShowingUser = true,
				HeightRequest = 100,
				WidthRequest = 960,
				VerticalOptions = LayoutOptions.FillAndExpand
			};

			// You can use MapSpan.FromCenterAndRadius 
//			map.MoveToRegion (MapSpan.FromCenterAndRadius (
//				new Position (37, -122), Distance.FromMiles (0.3)));
			// or create a new MapSpan object directly
			map.MoveToRegion (new MapSpan (new Position (0,0), 360, 360) );

			// add the slider
			var slider = new Slider (1, 18, 1);
			slider.ValueChanged += (sender, e) => {
				var zoomLevel = e.NewValue; // between 1 and 18
				var latlongdegrees = 360 / (Math.Pow(2, zoomLevel));
				Debug.WriteLine(zoomLevel + " -> " + latlongdegrees);
				if (map.VisibleRegion != null)
					map.MoveToRegion(new MapSpan (map.VisibleRegion.Center, latlongdegrees, latlongdegrees)); 
			};


			// create map style buttons
			var street = new Button { Text = "Street" };
			var hybrid = new Button { Text = "Hybrid" };
			var satellite = new Button { Text = "Satellite" };
			street.Clicked += HandleClicked;
			hybrid.Clicked += HandleClicked;
			satellite.Clicked += HandleClicked;
			var segments = new StackLayout { Spacing = 30,
				HorizontalOptions = LayoutOptions.CenterAndExpand,
				Orientation = StackOrientation.Horizontal, 
				Children = {street, hybrid, satellite}
			};


			// put the page together
			var stack = new StackLayout { Spacing = 0 };
			stack.Children.Add(map);
			stack.Children.Add (slider);
			stack.Children.Add (segments);
			Content = stack;


			// for debugging output only
			map.PropertyChanged += (sender, e) => {
				Debug.WriteLine(e.PropertyName + " just changed!");
				if (e.PropertyName == "VisibleRegion" && map.VisibleRegion != null)
					CalculateBoundingCoordinates (map.VisibleRegion);
			};
		}
开发者ID:zhenningshao,项目名称:xamarin-forms-samples,代码行数:55,代码来源:MapPage.cs

示例4: LamanPeta

		public LamanPeta ()
		{
			peta = new Map {
				IsShowingUser = true,
				VerticalOptions = LayoutOptions.FillAndExpand
			};

			peta.MoveToRegion (new MapSpan (new Position (0, 0), 360, 360));

			var slider = new Slider (1, 18, 2);
			slider.ValueChanged += (sender, e) => {
				var tingkatZoom = e.NewValue;
				var latLongDegree = 360 / (Math.Pow (2, tingkatZoom));
				if (peta.VisibleRegion != null) {
					peta.MoveToRegion (new MapSpan (peta.VisibleRegion.Center, latLongDegree, latLongDegree));
				}
			};

		    var jalan = new Button {Text = "Jalan"};
		    var hibrid = new Button {Text = "Hibrid"};
		    var satelit = new Button {Text = "Satelit"};

		    jalan.Clicked += ClickHandler;
		    hibrid.Clicked += ClickHandler;
		    satelit.Clicked += ClickHandler;

		    var segmen = new StackLayout
		    {
		        Spacing = 30,
		        HorizontalOptions = LayoutOptions.CenterAndExpand,
		        Orientation = StackOrientation.Vertical,
		        Children = {jalan, hibrid, satelit}
		    };

		    var stack = new StackLayout {Spacing = 0};
            stack.Children.Add(peta);
            stack.Children.Add(slider);
            stack.Children.Add(segmen);

		    Content = stack;

		    peta.PropertyChanged += (sender, e) =>
		    {
		        if (e.PropertyName == "VisibleRegion" && peta.VisibleRegion != null)
		        {
                    HitungKoordinat(peta.VisibleRegion);
		        }
		    };
		}
开发者ID:ibnuda,项目名称:WatIsDis,代码行数:49,代码来源:LamanPeta.cs

示例5: StoreMapPage

        public StoreMapPage()
        {
            var map = new Map (
                         MapSpan.FromCenterAndRadius (
                             new Position (30.0219504, -89.8830829), Distance.FromMiles (0.3))) {
                IsShowingUser = true,
                HeightRequest = 100,
                WidthRequest = 960,
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            // pin first address
            var positionA = new Position (30.517174,-90.463322);

            var pinA = new Pin {
                Type = PinType.Place,
                Position = positionA,
                Label = "Store A (HQ)",
                Address = "100 Janes Lane, \n Hammond, LA, \n 70401"
            };
            map.Pins.Add (pinA);

            // pin second address
            var positionB = new Position (37.42565,-122.13535);

            var pinB = new Pin {
                Type = PinType.Place,
                Position = positionB,
                Label = "Store B",
                Address = "Silicon Valley, Palo Alto, CA, \n 94025"
            };
            map.Pins.Add (pinB);

            // pin third address
            var positionC = new Position (42.360091,-71.09416);

            var pinC = new Pin {
                Type = PinType.Place,
                Position = positionC,
                Label = "Store C",
                Address = "Boston, MA, \n 02481"
            };
            map.Pins.Add (pinC);

            // add the slider
            var slider = new Slider (1, 18, 1);
            slider.ValueChanged += (sender, e) => {
                var zoomLevel = e.NewValue; // between 1 and 18
                var latlongdegrees = 360 / (Math.Pow (2, zoomLevel));
                //Debug.WriteLine(zoomLevel + " -> " + latlongdegrees);
                if (map.VisibleRegion != null)
                    map.MoveToRegion (new MapSpan (map.VisibleRegion.Center, latlongdegrees, latlongdegrees));
            };

            var stackLayout = new StackLayout { Spacing = 0 };
            stackLayout.Children.Add (map);
            stackLayout.Children.Add (slider);

            Content = stackLayout;
        }
开发者ID:camotts,项目名称:383-Admin-Portal-Mobile-App,代码行数:60,代码来源:StoreMapPage.cs

示例6: EventMapView

        public EventMapView(EventViewModel viewModel)
        {
            BindingContext = viewModel;

            var stack = new StackLayout();
            var map = new Map { IsShowingUser = true, VerticalOptions = LayoutOptions.FillAndExpand };

            MessagingCenter.Subscribe<EventViewModel>(this, "LocationSet", s =>
                {
                    var currentLocation = _vm.CurrentLocation;
                    map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(currentLocation.Latitude, currentLocation.Longitude),
                        Distance.FromMiles(0.3)));
                });

            MessagingCenter.Subscribe<EventViewModel>(this, "EventsLoaded", s =>
                {
                    map.Pins.Clear();
                    foreach (var v in _vm.Events)
                        if(v.Venue != null)
                            map.Pins.Add(new Pin
                                {
                                    Type = PinType.Place,
                                    Position = new Position(v.Venue.Latitude, v.Venue.Longitude),
                                    Address = v.Venue.Address1,
                                    Label = v.Name
                                });
                });
            stack.Children.Add(map);

            Content = stack;
        }
开发者ID:sguertl,项目名称:MeetupEvents-XamarinForms,代码行数:31,代码来源:EventMapView.cs

示例7: MapLocation

        public MapLocation()
        {

            map = new Map
            {
                /*  IsShowingUser = true,
                  HeightRequest = 100,
                  WidthRequest = 960,*/
                VerticalOptions = LayoutOptions.FillAndExpand
            };



            var stack = new StackLayout {Spacing = 0};
            /*    stack.Children.Add(map);*/
            stack.Children.Add(address);
            stack.Children.Add(latLong);
            stack.Children.Add(map);
            address.Text = "No Address Yet";
            latLong.Text = "No Lat/Lng Yet...";

            Content = stack;


            
             MessagingCenter.Subscribe<IGetLocation, CrashLocationResult>(this, "addressExists",
                 async (getLocation, s) =>
                 {
                     address.Text = s.Address + DateTime.Now.ToString();
                     latLong.Text = s.Lat.ToString() + "-" + s.Lng.ToString();
                 
                     map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(s.Lat, s.Lng
               ), Distance.FromMiles(0.9)));

                   
                     latLong.IsVisible = true;
                     address.IsVisible = true;

                     if (!_dialogOpen)
                     {
                         if (locationConfirmed = false)
                         {
                             await ConfirmLocation(s.AddressAsString);
                         }
                         
                     }

                 });
 


        }
开发者ID:Railgun-it,项目名称:autoresolve-app,代码行数:52,代码来源:MapLocation.cs

示例8: MainPage

		public MainPage()
		{
			var pos = new Xamarin.Forms.Maps.Position (-15.8046057, -47.896674);
			var Span = MapSpan.FromCenterAndRadius (pos, Distance.FromMiles (0.3));
			map = new Map (Span){ 
				IsShowingUser = true,
				HeightRequest = 100,
				WidthRequest = 960,
				VerticalOptions = LayoutOptions.FillAndExpand
			};


			// add the slider
			var slider = new Slider (1, 18, 1);
			slider.ValueChanged += (sender, e) => {
				var zoomLevel = e.NewValue; // between 1 and 18
				var latlongdegrees = 360 / (Math.Pow(2, zoomLevel));

				Debug.WriteLine(zoomLevel + " -> " + latlongdegrees);
				if (map.VisibleRegion != null)
					map.MoveToRegion(new MapSpan (map.VisibleRegion.Center, latlongdegrees, latlongdegrees)); 
			};


			// create map style buttons
			var street = new Button { Text = "Street" };
			var hybrid = new Button { Text = "Hybrid" };
			var satellite = new Button { Text = "Satellite" };
			street.Clicked += HandleClicked;
			hybrid.Clicked += HandleClicked;
			satellite.Clicked += HandleClicked;
			var segments = new StackLayout { Spacing = 30,
				HorizontalOptions = LayoutOptions.CenterAndExpand,
				Orientation = StackOrientation.Horizontal, 
				Children = {street, hybrid, satellite},
			};


			//			if (geoLocator.IsGeolocationAvailable == true) {
			//				geoLocator.PositionChanged
			//			}

			this.Content = new StackLayout
			{
				Children = {map, segments, slider}

			};

		}
开发者ID:CrazyTechLabsHackathonXamarinBSB,项目名称:bumpbusters,代码行数:49,代码来源:MainPage.cs

示例9: MapDemoPage

        public MapDemoPage()
        {
            Label header = new Label
            {
                Text = "Map",
                Font = Font.BoldSystemFontOfSize(50),
                HorizontalOptions = LayoutOptions.Center
            };

            View view;

            if (Device.OS == TargetPlatform.Android)
            {
                view = new Label
                {
                    Text = "Android applications require API key " +
                           "to use the Google Map service.",
                    Font = Font.SystemFontOfSize(NamedSize.Large),
                    VerticalOptions = LayoutOptions.CenterAndExpand
                };
            }
            else
            {
                Map map = new Map();
                view = map;

                // Let's visit Xamarin HQ in San Francisco!
                Position position = new Position(37.79762, -122.40181);
                map.MoveToRegion(new MapSpan(position, 0.01, 0.01));
                map.Pins.Add(new Pin
                    {
                        Label = "Xamarin",
                        Position = position
                    });
            }

            // Accomodate iPhone status bar.
            this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);

            // Build the page.
            this.Content = new StackLayout
            {
                Children = 
                {
                    header,
                    view
                }
            };
        }
开发者ID:Biotelligent,项目名称:xamarin-forms-samples,代码行数:49,代码来源:MapDemoPage.cs

示例10: MapDemoPage

        public MapDemoPage()
        {
            Label header = new Label
            {
                Text = "Map",
                FontSize = 50,
                FontAttributes = FontAttributes.Bold,
                HorizontalOptions = LayoutOptions.Center
            };

            View view;

            if (Device.OS == TargetPlatform.Android)
            {
                view = new Label
                {
                    Text = "Android applications require API key " +
                           "to use the Google Map service.",
                    FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                    VerticalOptions = LayoutOptions.CenterAndExpand
                };
            }
            else
            {
                Map map = new Map();
                view = map;

                // Let's visit Xamarin HQ in San Francisco!
                Position position = new Position(37.79762, -122.40181);
                map.MoveToRegion(new MapSpan(position, 0.01, 0.01));
                map.Pins.Add(new Pin
                    {
                        Label = "Xamarin",
                        Position = position
                    });
            }

            // Build the page.
            this.Content = new StackLayout
            {
                Children =
                {
                    header,
                    view
                }
            };
        }
开发者ID:cagm416,项目名称:MercianteCo,代码行数:47,代码来源:MapDemoPage.cs

示例11: GetGeoCS

        public GetGeoCS()
        {
            map = new Map(
                MapSpan.FromCenterAndRadius(
                    centerPosition, // 初期位置
                    Distance.FromKilometers(4d))) // 4km 圏内(?)
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HasZoomEnabled = true,
                IsShowingUser = true,
            };

            LatLabel = new Label
            {
                Text = "Lat:",
                HorizontalOptions = LayoutOptions.FillAndExpand,
                FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
            };
            LonLabel = new Label
            {
                Text = "Lon:",
                HorizontalOptions = LayoutOptions.FillAndExpand,
                FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
            };
            AddrLabel = new Label
            {
                Text = "Address:",
                FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
            };
            var getGeoButton = new Button
            {
                Text = "Get Location",
            };
            getGeoButton.Clicked += async (sender, e) =>
            {
                var locator = CrossGeolocator.Current;
                locator.DesiredAccuracy = 50;

                var location = await locator.GetPositionAsync(10000);

                LatLabel.Text = "Lat: " + location.Latitude.ToString("N6");
                LonLabel.Text = "Lon: " + location.Longitude.ToString("N6");

                var addr = await getAddress.GetJsonAsync(location.Latitude, location.Longitude) ?? "取得できませんでした";

                AddrLabel.Text = "Address: " + addr;

                // Map を移動させてピン打ち
                map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(location.Latitude, location.Longitude), Distance.FromKilometers(4d)));
                if (map.Pins.Count() > 0)
                    map.Pins.Clear();
                pin = new Pin
                {
                    Position = new Position(location.Latitude, location.Longitude),
                    Label = addr,
                };
                map.Pins.Add(pin);
            };

            Title = "XF_GpsSample";
            Content = new StackLayout
            {
                Padding = new Thickness(8),
                VerticalOptions = LayoutOptions.FillAndExpand,
                Children = {
                    getGeoButton,
                    new StackLayout
                    {
                        Orientation = StackOrientation.Horizontal,
                        Children =
                        {
                            LatLabel,
                            LonLabel,
                        }
                    },
                    AddrLabel,
                    map
                }
            };
        }
开发者ID:zcccust,项目名称:Study,代码行数:80,代码来源:GetGeoCS.cs

示例12: GetDireccion

        public async Task GetDireccion(string addressQuery, Map map)
        {
            var positions = (await (new Geocoder()).GetPositionsForAddressAsync(addressQuery)).ToList();
            if (!positions.Any())
                return;

            var position = positions.First();

            map.MoveToRegion(MapSpan.FromCenterAndRadius(position,
            Distance.FromMiles(0.1)));
            map.Pins.Add(new Pin
            {
                Label = addressQuery,
                Position = position,
                Address = addressQuery
            });
        }
开发者ID:paul33868,项目名称:MapsWithXaml,代码行数:17,代码来源:Coordenadas.cs

示例13: AddressCell

 internal static Cell AddressCell(PropertyInfo property, IContact context, Page parent = null)
 {
     var label = CreateLabel(property);
     var viewCell = new ViewCell 
     {
         Height = 150D
     };
     var pin = new Pin { Label = label };
     pin.SetBinding(Pin.AddressProperty, new Binding(property.Name, converter: AddressToStringConverter));
     pin.SetBinding(Pin.PositionProperty, new Binding(property.Name, converter: AddressConverter));
     var map = new Map(MapSpan.FromCenterAndRadius(pin.Position, Distance.FromMiles(0.1D)))
     {
         IsShowingUser = false,
         InputTransparent = false,
     };
     pin.PropertyChanged  += (sender, e) => {
         Console.WriteLine("Pin." + e.PropertyName + " Changed");
         map.MoveToRegion(MapSpan.FromCenterAndRadius(pin.Position, Distance.FromMiles(0.1D)));
     };
     map.PropertyChanging += (sender, e) => 
         Console.WriteLine("Map." + e.PropertyName + " Changed");
     pin.BindingContext = context;
     map.Pins.Add(pin);
     viewCell.View = map;
     return viewCell;
 }
开发者ID:ChandrakanthBCK,项目名称:xamarin-forms-samples,代码行数:26,代码来源:EditCellFactory.cs

示例14: MapPage

        public MapPage()
        {
            lista = new List<string>();

            Map map = new Map
            {
                IsShowingUser = true,
                HeightRequest = 100,
                WidthRequest = 960,
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            var searchAddress = new SearchBar { Placeholder = "Search Address" };
            //var getCoords = new Button { Text = "Street" };
            //lblatlong = new Label { Text = " " };

            //getCoords.Clicked += async (sender, e) =>
            //{
            //    var locator = CrossGeolocator.Current;

            //    locator.DesiredAccuracy = 50;

            //    var position = await locator.GetPositionAsync(timeout: 10000);

            //    lblatlong.Text = "Lat" + position.Latitude.ToString() + "Long" + position.Longitude.ToString();
            //};

            searchAddress.TextChanged += async (e, a) =>
            {
                var addressQuery = searchAddress.Text;
                //searchAddress.Text = "";
                //searchAddress.Focus();
                //searchAddress.Unfocus();

                var positions = (await(new Geocoder()).GetPositionsForAddressAsync(addressQuery)).ToList();
                if (!positions.Any())
                    return;

                foreach (var pos in positions)
                {
                    var locationAddress = (await(new Geocoder()).GetAddressesForPositionAsync(pos));
                    if (locationAddress != null && locationAddress.ToList().Count > 0)
                        lista.Add(locationAddress.ToList()[0]);
                }
            };

            searchAddress.SearchButtonPressed += async (e, a) =>
            {
                lista = new List<string>();

                var addressQuery = searchAddress.Text;
                searchAddress.Text = "";
                searchAddress.Unfocus();

                var positions = (await (new Geocoder()).GetPositionsForAddressAsync(addressQuery)).ToList();
                if (!positions.Any())
                    return;

                var position = positions.First();
                map.MoveToRegion(MapSpan.FromCenterAndRadius(position,
                    Distance.FromMiles(0.1)));
                map.Pins.Add(new Pin
                {
                    Label = addressQuery,
                    Position = position,
                    Address = addressQuery
                });
            };

            var MyList = new ListView
            {
                ItemsSource = lista
            };

            var segments = new StackLayout
            {
                Spacing = 30,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                Orientation = StackOrientation.Vertical,
                Children = { searchAddress, MyList }
            };

            var stack = new StackLayout { Spacing = 0 };
            //stack.Children.Add(slider);
            stack.Children.Add(segments);
            stack.Children.Add(map);
            Content = stack;
        }
开发者ID:paul33868,项目名称:AAJMaps,代码行数:88,代码来源:MapPage.cs

示例15: MapScreen

        public MapScreen()
        {
            #region imageIconLayout
            StackLayout logoLayout = new StackLayout {
                BackgroundColor = Color.Black,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.FillAndExpand,
                Padding = new Thickness (4, 0, 0, 0)
            };
            #endregion

            #region imageIcons
            Image logo = new Image {
                Source = "QutLogoWhite.png",
                HeightRequest = (App.screenHeight / 12) - 4,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                VerticalOptions = LayoutOptions.CenterAndExpand
            };
            #endregion

            logoLayout.Children.Add (logo);

            #region mapContent
            StackLayout mapContent = new StackLayout {
                Padding = new Thickness (0, 2, 0, 0),
                BackgroundColor = Color.Black,
                Spacing = 0
            };

            var map = new Map (
                MapSpan.FromCenterAndRadius (new Position (37, -122), Distance.FromKilometers (10))) {
                IsShowingUser = true,
                HasZoomEnabled = true,
                HasScrollEnabled = true,
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            var govHouse = new Pin {
                Type = PinType.Place,
                Position = new Position (-27.4773531, 153.0289662),
                Label = "Old Government House",
                Address = "2 George Street, Brisbane, QLD 4000"
            };

            var parHouse = new Pin {
                Type = PinType.Place,
                Position = new Position (-27.4754214, 153.0249879),
                Label = "Parliament House",
                Address = "George St, Brisbane QLD 4000"
            };

            var execBuild = new Pin {
                Type = PinType.Place,
                Position = new Position (-27.4727061, 153.0242916),
                Label = "Executive Building",
                Address = "130 William Street, Brisbane QLD 4000"
            };

            var innsCourt = new Pin {
                Type = PinType.Place,
                Position = new Position (-27.4693386, 153.0186364),
                Label = "Inns of Court",
                Address = "107 North Quay, Brisbane QLD 4000"
            };

            var lawCourts = new Pin {
                Type = PinType.Place,
                Position = new Position (-27.468916, 153.0192682),
                Label = "Commonwealth Law Courts",
                Address = "119 North Quay, Brisbane QLD 4000"
            };

            var magCourt = new Pin {
                Type = PinType.Place,
                Position = new Position (-27.468916, 153.0192682),
                Label = "Magistrates' Court",
                Address = "363 George Street, Brisbane QLD 4000"
            };

            var queenCourts = new Pin {
                Type = PinType.Place,
                Position = new Position (-27.4674193, 153.0192154),
                Label = "QEII Courts Complex",
                Address = "415 George St, Brisbane QLD 4000"
            };

            var loc = CrossGeolocator.Current;
            loc.DesiredAccuracy = 100;

            var getLocation = new TapGestureRecognizer();
            getLocation.Tapped += async (sender, e) => {
                var posG = await loc.GetPositionAsync(timeoutMilliseconds:10000);
                map.MoveToRegion(new MapSpan (map.VisibleRegion.Center, posG.Latitude, posG.Longitude));
            };

            getLocation.NumberOfTapsRequired = 2;

            map.MapType = MapType.Street;
            map.PropertyChanged += (sender, e) => {
                Debug.WriteLine(e.PropertyName + " just changed!");
//.........这里部分代码省略.........
开发者ID:EclipseSystems,项目名称:INB302-IT-Capstone-Unit,代码行数:101,代码来源:MapScreen.cs


注:本文中的Map.MoveToRegion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。