1. 程式人生 > >iOS基於百度地圖的開發(1)——使用者當前位置

iOS基於百度地圖的開發(1)——使用者當前位置

首先需要設定mapView的屬性:
self.mapView = [[[BMKMapView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)] autorelease];//我們動態建立一個MapView物件

mapView.showsUserLocation = YES;//可以顯示使用者當前位置
mapView.zoomEnabled = YES;//允許Zoom
mapView.scrollEnabled = YES;//允許Scroll
mapView.mapType = BMKMapTypeStandard;//地圖型別為標準,可以為衛星,可以開啟或關閉交通
mapView.delegate = self;//自身做代理

需要在地圖中央顯示使用者當前位置時的方法是:

[mapView setCenterCoordinate:mapView.userLocation.coordinate animated:YES];

根據需要,可以設定當前地圖的Zoom級別,例如:
[mapView setZoomLevel:15];