现在的位置: 首页 > 综合 > 正文

xamarin iOS地图开发

2019年05月16日 ⁄ 综合 ⁄ 共 774字 ⁄ 字号 评论关闭
			<span style="font-family: Arial, Helvetica, sans-serif;">this.mapView.MapType = MonoTouch.MapKit.MKMapType.Standard;</span>
			this.mapView.ShowsUserLocation = true;

			locationManager = new CLLocationManager ();
		
			int deviceVersion=Convert.ToInt32(UIDevice.CurrentDevice.SystemVersion.Split('.')[0]);
			if (deviceVersion < 8) {
			} else {
				locationManager.RequestWhenInUseAuthorization ();
			}

			locationManager.StartUpdatingLocation ();
			locationManager.LocationsUpdated += LocationManagerUpdate;
<pre name="code" class="csharp">		void LocationManagerUpdate (object sender, CLLocationsUpdatedEventArgs e)
		{
			locationManager.StopUpdatingLocation ();
			MKCoordinateSpan theSpan = new MKCoordinateSpan (0.2,0.2);
			MKCoordinateRegion theRegion = new MKCoordinateRegion (locationManager.Location.Coordinate,theSpan);
			this.mapView.SetRegion (theRegion,true);
		}


抱歉!评论已关闭.