{
// 1.获取用户输入的起点和终点
NSString *startStr = @”北京”;
NSString *endStr = @”遵义”;
if (startStr == nil || startStr.length == 0 ||
endStr == nil || endStr.length == 0) {
NSLog(@”请输入起点或者终点”);
return;
}
// 2.利用GEO对象进行地理编码获取到地标对象(CLPlacemark )
// 2.1获取开始位置的地标
[self.geocoder geocodeAddressString:startStr completionHandler:^(NSArray *placemarks, NSError *error) {
if (placemarks.count == 0) return;
// 开始位置的地标
CLPlacemark *startCLPlacemark = [placemarks firstObject];
// 添加起点的大头针
HMAnnotation *startAnno = [[HMAnnotation alloc ] init];
startAnno.title = startCLPlacemark.locality;
startAnno.subtitle = startCLPlacemark.name;
startAnno.coordinate = startCLPlacemark.location.coordinate;
[self.mapVIew addAn
地图 获取线路信息
最新推荐文章于 2022-09-08 18:52:51 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)