|
|
@@ -43,21 +43,28 @@ typedef enum {
|
|
|
}
|
|
|
NSString* addr = [location valueForKey:@"addr"];
|
|
|
NSString* name = [location valueForKey:@"name"];
|
|
|
- double longitude = [[location valueForKey:@"lon"] doubleValue];
|
|
|
- double latitude = [[location valueForKey:@"lat"] doubleValue];
|
|
|
-
|
|
|
- // 创建大头针(标注)的数据模型(此处不创建视图,视图通过MKMapView的委托设置回调方法来生成的)
|
|
|
- AMShipAnnotation *ann = [[AMShipAnnotation alloc] init];
|
|
|
- CLLocationCoordinate2D c2d = CLLocationCoordinate2DMake(latitude, longitude);
|
|
|
- // 指定大头针的经纬度坐标(位置)以及附加的信息
|
|
|
- ann.coordinate = c2d;
|
|
|
- ann.title = name;
|
|
|
- ann.subtitle = addr;
|
|
|
- ann.priority = priority;
|
|
|
-
|
|
|
- // 将大头针数据模型添加到MKMapView上管理
|
|
|
- [self.mapView addAnnotation:ann];
|
|
|
-
|
|
|
+ NSString *lonStr = [location valueForKey:@"lon"];
|
|
|
+ NSString *latStr = [location valueForKey:@"lat"];
|
|
|
+ if (lonStr && lonStr.length > 0 && latStr && latStr.length > 0) {
|
|
|
+
|
|
|
+ double longitude = [lonStr doubleValue];
|
|
|
+ double latitude = [latStr doubleValue];
|
|
|
+
|
|
|
+ // 创建大头针(标注)的数据模型(此处不创建视图,视图通过MKMapView的委托设置回调方法来生成的)
|
|
|
+ AMShipAnnotation *ann = [[AMShipAnnotation alloc] init];
|
|
|
+ CLLocationCoordinate2D c2d = CLLocationCoordinate2DMake(latitude, longitude);
|
|
|
+ // 指定大头针的经纬度坐标(位置)以及附加的信息
|
|
|
+ ann.coordinate = c2d;
|
|
|
+ ann.title = name;
|
|
|
+ ann.subtitle = addr;
|
|
|
+ ann.priority = priority;
|
|
|
+
|
|
|
+ // 将大头针数据模型添加到MKMapView上管理
|
|
|
+ [self.mapView addAnnotation:ann];
|
|
|
+
|
|
|
+ } else {
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- (void)showShipAnnotaion:(NSDictionary *)annotation {
|