ios开发中地图应用
2013-04-11 17:06 三戒1993 阅读(131) 评论(0) 编辑 收藏 举报BMKPointAnnotation* annotation = [[BMKPointAnnotation alloc]init];
CLLocationCoordinate2D coord=CLLocationCoordinate2DMake(mStore.mnLatitude, mStore.mnLongitude);// 商家坐标
mapView.centerCoordinate = coor; // 以商家坐标为中心
annotation.coordinate = coor;
annotation.title = mStore.mstrName;
[mapView addAnnotation:annotation];
2、google地图
参考:https://developer.apple.com/library/ios/#samplecode/Regions/Introduction/Intro.html
CLLocationCoordinate2D coord=CLLocationCoordinate2DMake(mStore.mnLatitude, mStore.mnLongitude);// 商家坐标
CLRegion *newRegion = [[CLRegion alloc] initCircularRegionWithCenter:coord
radius:1000.0
identifier:[NSString stringWithFormat:@"%f, %f", regionsMapView.centerCoordinate.latitude, regionsMapView.centerCoordinate.longitude]];
// Create an annotation to show where the region is located on the map.
RegionAnnotation *myRegionAnnotation = [[RegionAnnotation alloc] initWithCLRegion:newRegion];
myRegionAnnotation.coordinate = newRegion.center;
myRegionAnnotation.title = mStore.mstrName;
// 定位到目标坐标
MKCoordinateRegion storeLocation = MKCoordinateRegionMakeWithDistance(coord, 4500.0, 4500.0); // 值越小,地图越大,越精确
[regionsMapView setRegion:storeLocation animated:YES];
[regionsMapView addAnnotation:myRegionAnnotation];
[myRegionAnnotation release];
// Start monitoring the newly created region.
[locationManager startMonitoringForRegion:newRegion desiredAccuracy:kCLLocationAccuracyBest];
[newRegion release];