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