我将如何使用 MapKit 在带有邮政编码/邮编的商店上放置图钉

发布于 2024-10-01 01:31:39 字数 148 浏览 0 评论 0原文

如果我对特定商店或企业(或餐厅等)的唯一信息是其名称、邮政编码(或邮政编码)和国家/地区,那么我将如何创建一个 MKMapView 来定位商店并在该位置上放置图钉? 如果我输入“Pizza Paradiso,WC1E 7BS,UK”,那么就像复制一样,除了没有信息气泡(但带有图钉)

If the only information I have for a particular store or business (or restaurant etc) is its Name, Postcode (or Zipcode) and Country, how would I create an MKMapView which locates the store and drops a pin on the location?
So kind of replicating if I typed in "Pizza Paradiso, WC1E 7BS, UK", except without the info bubble (but with pin)

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

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

发布评论

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

评论(1

世界和平 2024-10-08 01:31:39

这称为地理编码,MapKit 目前仅使用 MKReverseGeocoder 类进行反向地理编码(从纬度/经度到地址)。

要进行地理编码,您必须使用其他一些 api,例如 Google 地理编码 API,然后获取它提供的纬度和经度来创建一个区域,并将其传递给地图视图的 setRegion:animated: 方法。

要放置图钉,您需要获取生成的纬度/经度并创建一个注释对象,然后使用 addAnnotation 将其添加到地图视图中。

This is called geocoding and the MapKit currently only does reverse-geocoding (from lat/long to address) using the MKReverseGeocoder class.

To do geocoding, you'll have to use some other api like the Google Geocoding API and then take the latitude and longitude it gives you to create a region which you pass to the map view's setRegion:animated: method.

To drop a pin, you would take the resulting lat/long and create an annotation object and add it to the map view using addAnnotation.

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