没有进入OpenGL(Quartz 2D就可以了):
假设我有一张图片,我希望以某种流畅的方式在地图上移动.例如,飞机在地图上"飞行"的图像.我已经能够使用MKAnnotation,NSTimer和摆弄纬度/经度变化率和定时器速率来做到这一点.但是,我认为这并不理想,虽然结果看起来相当不错.你能想到一个更好的方法吗?
现在让我们说我希望这个图像是动画的(想想:动画gif).我无法通常UIImageView使用一系列animationFrames因为我在MKAnnotationView中访问的所有内容都是一个UIImage.你们怎么解决这个问题?
我意识到可以使用包含animationImages的地图顶部的UIImageView来处理#2.然而,根据用户在现实世界中的移动或用户缩放(我的应用程序中不允许滚动),我必须手动处理平面或火箭的移动或者地图视图区域变化的任何内容.
你怎么看?
我正在使用下面的代码在地图上显示自定义图像(而不是默认引脚).但是,当我点击某个项目(并显示标注)时,图像将恢复为默认的红色图钉.即使显示标注,如何保留自定义图像?
- (MKAnnotationView *) mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation
{
MKPinAnnotationView *pinAnnotation = nil;
if (annotation != mapView.userLocation)
{
static NSString *pinID = @"mapPin";
pinAnnotation = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:pinID];
if (pinAnnotation == nil)
pinAnnotation = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:pinID] autorelease];
// Set the image
pinAnnotation.image = [UIImage imageNamed:@"TestIcon.png"];
// Set ability to show callout
pinAnnotation.canShowCallout = YES;
// Set up the disclosure button on the right side
UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
pinAnnotation.rightCalloutAccessoryView = infoButton;
[pinID release];
}
return pinAnnotation;
[pinAnnotation …Run Code Online (Sandbox Code Playgroud) 谷歌地图是否有任何网址,它会返回地址的纬度和经度.我想在iPhone Map工具包中使用这些lat和long细节来绘制一些信息.
我正在使用mapkit和CLLocationManager开发一个iphone应用程序.
我在地图上放了很多MKPinAnnotationView(大约100个),我希望在收到它时更新所有标注的副标题用户距离.
怎么做 ?
谢谢
我尝试用新位置更新字幕标注,但效果不好.
在我的MyAppDelegate.h中
extern NSString * const GMAP_USERLOCATION_CHANGED;
@interface MyAppDelegate : NSObject <UIApplicationDelegate> {
CLLocationManager *locationManager;
CLLocation *userLocation;
}
@property (nonatomic, retain) CLLocationManager *locationManager;
@property (nonatomic, retain) CLLocation *userLocation;
@end
Run Code Online (Sandbox Code Playgroud)
在我的MyAppDelegate.m中
@implementation MyAppDelegate
NSString * const GMAP_USERLOCATION_CHANGED = @"gMapUserLocationChanged";
@synthesize locationManager, userLocation;
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
userLocation = nil;
[[self locationManager] startUpdatingLocation];
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
}
#pragma mark -
#pragma mark Core Location delegate
- (CLLocationManager *)locationManager
{
if (locationManager != nil)
{
return locationManager; …Run Code Online (Sandbox Code Playgroud) iphone objective-c mapkit mkpinannotationview mkannotationview
在我看来,我在顶部有导航栏,剩下的视图充满了地图视图.我的地图视图有针脚,点击针脚时,它也会显示注释.在右上方导航栏中我有一个按钮,点击它,我想删除弹出的注释视图.(那里有什么注释视图,我想从视图中删除).有人可以告诉我该怎么做.
我们可以做的简单任务是将一些触摸事件发送到地图视图,这将隐藏它.....我是对的.怎么做?
我在地图上显示一个图钉,但我无法自定义注释视图的显示.由于某种原因,我的viewForAnnotation没有被调用.这是didFinishLaunchingWithOptions方法.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[mapView setDelegate:self];
locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager setDistanceFilter:kCLDistanceFilterNone];
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[mapView setShowsUserLocation:YES];
// Override point for customization after application launch.
[self.window makeKeyAndVisible];
return YES;
}
Run Code Online (Sandbox Code Playgroud)
这是我永远不会被调用的viewForAnnotation方法.
- (MKAnnotationView *)mv:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
NSLog(@"viewForAnnotation");
if([annotation isKindOfClass:[MKUserLocation class]])
return nil;
static NSString *annotationIdentifier = @"AnnotationIdentifier";
MKPinAnnotationView *pinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:annotationIdentifier];
[pinView setPinColor:MKPinAnnotationColorGreen];
pinView.animatesDrop = YES;
pinView.canShowCallout = YES;
UIImageView *houseIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"house.png"]];
pinView.leftCalloutAccessoryView = houseIconView;
[houseIconView …Run Code Online (Sandbox Code Playgroud) 如何将MKMapView上的距离(例如400米)转换为UIView的距离?我想显示MKAnnotationView,它取决于MKMapView上的当前缩放级别.
我不知道我做错了什么,但它不会工作.
我mapView: viewForAnnotation:看起来像这样:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
MKAnnotationView *aView = [mapView dequeueReusableAnnotationViewWithIdentifier:@"ImageMapView"];
if (!aView)
{
aView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"ImageMapView"];
aView.canShowCallout = YES;
aView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
aView.leftCalloutAccessoryView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
}
[(UIImageView *)aView.leftCalloutAccessoryView setImage:nil];
aView.annotation = annotation;
return aView;
}
Run Code Online (Sandbox Code Playgroud)
所以每个新的注释都以左侧标注中的空白图像视图开始.
现在当触摸标注时,执行下一个代码:
- (void)mapView:(MKMapView *)mapView didDeselectAnnotationView:(MKAnnotationView *)view
{
//loading an image
[(UIImageView *)view.leftCalloutAccessoryView setImage:image];
}
Run Code Online (Sandbox Code Playgroud)
在日志记录的帮助下,我知道图像的网址和数据都没问题,图像本身也不是零,但左侧标注中没有显示任何内容.
任何人都可以建议我如何追查这个问题的根源?
我添加了一些日志,所以我可以看到发生了什么:
- (void)mapView:(MKMapView *)mapView didDeselectAnnotationView:(MKAnnotationView *)view
{
UIImage *image = …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用MapKit构建一个简单的应用程序,该应用程序将在应用程序启动时自动搜索特定位置,并在地图上的地点放置引脚.我看到了各种加载位置的方法(lat/lon等),但没有任何东西可以让我搜索特定的商家名称,餐馆名称等.
我期待与Apple Maps合作.但是,如果谷歌地图是一个比它更好的解决方案.
任何帮助,将不胜感激.谢谢
mapkit ×10
iphone ×7
ios ×4
objective-c ×3
animation ×1
annotations ×1
apple-maps ×1
google-maps ×1
ipad ×1
mkmapview ×1
xcode ×1