请帮我,我想获取droppin的坐标,并且还想获取离线地图图块中的当前位置。这怎么可能?请帮帮我。如何放置图钉并从离线地图图块中获取当前位置和坐标?
回答
您不会使用MKMapView在离线地图中获取当前位置。要完成所有任务,请使用cloudmade地图API。
不错的云找地图API =) – henghonglee 2012-02-20 06:19:37
实现此代码...
-(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:
(id <MKAnnotation>)annotation {
MKPinAnnotationView *pinView = nil;
if(annotation != mapView.userLocation)
{
static NSString *defaultPinID = @"com.invasivecode.pin";
pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
if (pinView == nil) pinView = [[[MKPinAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease];
pinView.pinColor = MKPinAnnotationColorRed;
pinView.canShowCallout = YES;
pinView.animatesDrop = YES;
}
else {
[mapView.userLocation setTitle:@"I am here"];
}
return pinView;
}
和当前位置....据我所知,你无法在模拟器获得当前位置。所以,一个选项是在你的项目中添加.gpx文件。您可以通过使用.gpx进行搜索来添加此项。在该文件中设置当前位置,lat和lon。这就是我所知道的。我刚刚完成了相同的任务...祝你好运.. :)
你好,但我想要在离线地图中不是在Mapview中做到这一点。我有地图图块和我想放下图钉的图块。 – 2012-02-20 06:00:07
您需要详细说明您的离线地图,以及互联网连接的程度,如果mapview不是您需要的,您可能必须自行完成坐标计算。 – henghonglee 2012-02-20 06:18:52
这个方法会给你选定的方法和上面的方法(Goti提到的)的坐标是将注释放在所需的位置。
-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)annotationView
{
if([annotationView class]==[MKAnnotationView class])
{
CLLocationCoordinate2D coord = annotationView.annotation.coordinate;
NSLog(@"Latitude -> %f",coord.latitude);
NSLog(@"Longitude -> %f",coord.longitude);
}
}
希望它会有帮助。
但我离线地图瓷砖没有mapview。 – 2012-02-20 06:06:31
MKMapView *locationMap = [[MKMapView alloc] initWithFrame:CGRectMake(0,86, 320, 334)];
[self.view addSubview:locationMap];
locationMap.alpha = 1.0;
locationMap.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin;
locationMap.mapType = MKMapTypeStandard;
locationMap.delegate = self;
locationMap.showsUserLocation = YES;
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation
{
MKAnnotationView *a = [ [ MKAnnotationView alloc ] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
// a.title = @"test";
if (a == nil)
a = [ [ MKAnnotationView alloc ] initWithAnnotation:annotation reuseIdentifier: @"currentloc" ];
NSLog(@"%f",a.annotation.coordinate.latitude);
NSLog(@"%f",a.annotation.coordinate.longitude);
CLLocation* currentLocationMap = [[[CLLocation alloc] initWithLatitude:a.annotation.coordinate.latitude longitude:a.annotation.coordinate.longitude] autorelease];
[self coordinatesToDMS:currentLocationMap];
MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:a reuseIdentifier:@"currentloc"];
if(a.annotation.coordinate.longitude == mapView.userLocation.coordinate.longitude || a.annotation.coordinate.latitude == mapView.userLocation.coordinate.latitude )
{
if ([annotation isKindOfClass:MKUserLocation.class]) {
//user location view is being requested,
//return nil so it uses the default which is a blue dot...
return nil;
}
//a.image = [UIImage imageNamed:@"userlocation.png"];
//a.pinColor=;
}
else
{
// annView.image =[UIImage imageNamed:@"map-pin.png"];
//PinFirst=FALSE;
//annView.pinColor = [UIColor redColor];
// annView.annotation=annotation;
}
annView.animatesDrop = YES;
annView.draggable = YES;
annView.canShowCallout = YES;
return annView;
}
- 1. 如何在离线地图图块中放置多个图钉,并且还可以获得更多图钉?
- 2. 在地图视图中放置图钉
- 3. 如何在iphone中获取当前位置在地图上的坐标值?
- 4. 获取当前位置的Google地图
- 5. 在地图上获取当前位置
- 6. 如何使用iphone中的谷歌地图从当前位置获取地标?
- 7. 如何获取Google地图链接从当前位置?
- 8. 当前位置与地图
- 9. 如何移除默认的Google地图当前位置图标?
- 10. 在地图中放置位置标记?
- 11. 谷歌地图当前位置绘图
- 12. 如何获取一对经纬度浮点数并获取MKMapView放置一个图钉并显示位置?
- 13. 如何获取当前位置的谷歌地图?
- 14. Angularjs使用标记移动地图并获取位置当前标记
- 15. 如何在坐标中获取视图的位置?
- 16. 如何在MapView上放置不随地图移动的图钉?
- 17. 从坐标获取位置?
- 18. 如何从Matlab中的图像获取onclick坐标像素值和位置?
- 19. 地图视图 - 移动地图视图后的当前位置
- 20. 如何将视图放置在特定位置(x,y坐标)
- 21. 单点击放置图钉
- 22. 如何从视图中获取位置?
- 23. 放大当前位置在地图视图
- 24. Nutiteq在地图上获取某个位置的坐标
- 25. 获取位置之间的所有坐标iphone地图套件
- 26. 坐标位置图像Android
- 27. 如何在地图视图中绘制从当前位置到目的位置的路线xamarin iOS
- 28. 在当前位置和单独位置放置地标mkmapview
- 29. 无法在Google地图片段中获取当前位置
- 30. 无法在Google地图中获取当前位置
为什么在这个问题上减点?如果你知道的话请告诉我? – 2012-02-20 05:29:52
那些谁是专家,他们发现这个问题很愚蠢,所以他们中的一个可能会减少你的分数。 – HarshIT 2012-02-20 06:01:48
如果这是肮脏的问题,那么为什么没有人能够给出答案? – 2012-02-20 06:10:06