xcode 如何在 iphone 中使用地图视图?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1525314/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to use mapview in iphone?
提问by Shweta Simply
I want to display a map using two locations in which one updates continously. And also I want to show a custom pin icon in map view.
我想使用两个位置显示一个地图,其中一个位置不断更新。而且我还想在地图视图中显示自定义图钉图标。
回答by jantimon
See this link: Playing with map kit
请参阅此链接:使用地图套件
I started looking at the Map Kit API for developing a quick and dirty - Find where you parked your car - application.
There is no programming guide for Map Kit yet on the developer pages for Apple, So I decided to share some some of it here.
我开始研究 Map Kit API 以开发一个快速而肮脏的 - 查找您停放汽车的位置 - 应用程序。
Apple 的开发者页面上还没有 Map Kit 的编程指南,所以我决定在这里分享一些。
Part 3 might be what you are looking for:
(source: objectgraph.com)
第 3 部分可能是您正在寻找的内容:(
来源:objectgraph.com)
回答by viral
To Show your icon, Put this code where you have implemented your mapView.
要显示您的图标,请将此代码放在您实现 mapView 的位置。
Also add car icon to your project.
还将汽车图标添加到您的项目中。
-(MKAnnotationView*)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
MKPinAnnotationView *view = nil;
if (annotation != mapView.userLocation) {
view = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"myAnnotationIdentifier"];
if (!view) {
view = [[MKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:@"myAnnotationIdentifier"];
view.canShowCallout = YES;
view.image = [UIImage imageNamed:@"car.png"];
}
}
return view;
}