MapKit 的注释问题

发布于 2024-09-18 01:55:37 字数 625 浏览 7 评论 0原文

好的,我的 MapKit 注释遇到了一些问题。

首先,我想要每个注释的标注。我根本不知道该怎么做! :( 我有两个 NSString(地点名称和简短描述)。然后我需要能够记录标注上的点击 - 这样我就可以启动披露视图。

其次,我想更改用户位置的视图 ,

目前

- (MKAnnotationView *) mapView:(MKMapView *)myMapView viewForAnnotation:(id <MKAnnotation>) annotation{
    MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
    annView.animatesDrop=TRUE;
    return annView;
}

所有注释都通过以下代码设置为“默认”引脚注释视图:我更愿意将用户位置注释设置为默认的蓝色脉冲圆圈,但至少我希望能够将 pinColor 属性更改为不同的颜色,以便用户可以区分自己的位置和搜索结果,

我希望有人可以帮助我,

谢谢。

Ok, so I've got some issues with my MapKit annotations.

First of all, I want a callout for each annotation. I can't find out how to do this at all! :( I have two NSStrings (name of the place and a short description). Then I need to be able to log the click on the callout - so I can launch a disclosure view.

Secondly I want to change the view for the user location annotation.

At the moment all annotations are set to the "default" pin annotation view by way of this code:

- (MKAnnotationView *) mapView:(MKMapView *)myMapView viewForAnnotation:(id <MKAnnotation>) annotation{
    MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
    annView.animatesDrop=TRUE;
    return annView;
}

I would prefer to have the user location annotation set to the default blue pulsing circle thing, but at least I want to be able to change the pinColor property to a different color, so the user can distinguish between their own location and the results of their search.

I hope somebody can help me.

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甲如呢乙后呢 2024-09-25 01:55:37

我认为您应该考虑使用 shownUserLocation 来描述您的用户位置 - 它是平台的标准 UI,可帮助人们在应用程序之间获得一致的体验。当然,您可以为用户位置提供一些自定义注释,但为什么要重新发明人们习惯在地图应用程序和许多第三方应用程序上看到的内容呢?

您应该花时间查看 Apple 的 MapKit 代码示例,您需要做的一切都在那里。这对您来说尤其是一个很好的起点:

http://developer.apple.com/iphone/prerelease/library/samplecode/MapCallouts/Introduction/Intro.html

I think you should consider using showsUserLocation to depict your users location - it's the standard UI for the platform and helps people get a consistent experience across apps. Sure you can come up with some custom annotation for user location but why re-invent what people are used to seeing on the maps app and on many 3rd party apps?

You should take the time to review Apple's code samples for MapKit everything you need to do is there. This one in particular is a good starting point for you:

http://developer.apple.com/iphone/prerelease/library/samplecode/MapCallouts/Introduction/Intro.html

雨落星ぅ辰 2024-09-25 01:55:37

嗯...问题是我不知道当前位置正在使用哪个注释。没关系 - 我现在已经找到了。类似于 if(annotation == mapView.userlocation){ return nil; } 或类似的。 :) 不过还是谢谢你的帮助

hmm... the problem was i didn't know which annotation was the one being used by current location. Its ok - I've found it now. Something like if(annotation == mapView.userlocation){ return nil; } or similar. :) Thanks for your help though

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文