4
A
回答
4
你需要创建一个实现MKAnnotation协议委托:
@interface AnnotationDelegate : NSObject <MKAnnotation> {
CLLocationCoordinate2D coordinate;
}
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
- (id) initWithCoordinate:(CLLocationCoordinate2D)coord;
@end
@implementation AnnotationDelegate
@synthesize coordinate;
- (id) initWithCoordinate:(CLLocationCoordinate2D)coord
{
coordinate.latitude = coord.latitude;
coordinate.longitude = coord.longitude;
return self;
}
@end
对于每一个地图点,你需要实例化AnnotionDelegate对象之一(传入点的坐标),并把它添加到的MKMapView:
AnnotationDelegate * annotationDelegate = [[[AnnotationDelegate alloc] initWithCoordinate:coordinate] autorelease];
[self._mapView addAnnotation:annotationDelegate];
0
if([points retainCount] > 0)
{
[points release];
points = nil;
}
if([annotationAry retainCount] > 0)
{
[annotationAry release];
annotationAry = nil;
}
points = [[NSMutableArray alloc]init];
annotationAry = [[NSMutableArray alloc]init];
for(int i=0;i<[longitudeary count];i++)
{
CLLocation* currentLocation1 = [[CLLocation alloc] initWithLatitude:[[latitudeary objectAtIndex:i]doubleValue] longitude:[[longitudeary objectAtIndex:i]doubleValue]];
[points addObject:currentLocation1];
}
for(int i=0;i<[points count];i++)
{
// CREATE THE ANNOTATIONS AND ADD THEM TO THE MAP
CSMapAnnotation* annotation = nil;
// create the start annotation and add it to the array
annotation = [[[CSMapAnnotation alloc] initWithCoordinate:[[points objectAtIndex:i] coordinate]
annotationType:CSMapAnnotationTypeImage
title:@"123456..."
shID:[shIDary objectAtIndex:i]
catID:[catIDary objectAtIndex:i]
ciggUse:[ciggaretteUSEary objectAtIndex:i]
wifiUse:[wifiUSEary objectAtIndex:i]
controller:self]autorelease];
[annotationAry addObject:annotation];
}
[mapViewmy addAnnotations:[NSArray arrayWithArray:annotationAry]];
1
NSString * urlString = nil;
urlString = [NSString stringWithFormat: @"http://maps.google.com/maps?saddr=%f,%f&daddr=%@",12.58, 77.35, [NSString stringWithFormat:@"%@,%@,%@",[detailInfoDict valueForKey:@"address"],[detailInfoDict valueForKey:@"city"],[detailInfoDict valueForKey:@"state"]]];
urlString = [urlString stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: urlString]]
相关问题
- 1. 在地图视图中放置图钉
- 2. 如何为地图视图设置缩放级别?
- 3. 如何在地图上添加别针?
- 4. 在谷歌地图上放置针点
- 5. 如何在地图视图上放置注释并保存销
- 6. 如何在谷歌地图中设置缩放级别
- 7. 如何在android中设置地图视图中的地形视图?
- 8. 在地图视图中设置位置
- 9. 在视图中放置图像
- 10. 仅在视图中放置Google地图标记
- 11. 如何在FloatingActionButton上放置视图?
- 12. MKAnnotation - 地图别针标注在其他地图别针后面弹出
- 13. 如何在导航视图控制器上放置视图?
- 14. 如何在两个视图下放置视图?
- 15. 如何将地图视图中的针脚发回到呼出视图?
- 16. 我如何下载并在Android视图中放置图像
- 17. 缩放放置在图像视图中的图像的控件?
- 18. 在地图中放置地标
- 19. 在地图中放置位置标记?
- 20. Android地图视图(放置一个别针并移动它,向它添加一个自定义标签)
- 21. 如何在地图文件视图中设置dwFileOffsetHigh&dwFileOffsetLow值?
- 22. 如何在Android中设置Google地图的街景视图?
- 23. 如何在我的地图视图中设置streetView
- 24. 如何在我的地图视图中设置streetView
- 25. 如何动态设置Google地图自定义缩放级别?
- 26. 谷歌地图 - 如何设置缩放级别
- 27. 放大当前位置在地图视图
- 28. 如何使用Swift正确地在照片上放置图像视图
- 29. monodroid如何在图像上放置图像并放置图像
- 30. 如何使用本地化将图像放入视图中?
您应该接受一些其他问题。您将以这种方式获得更多答案。 – RedBlueThing 2009-11-27 06:14:17