Xcode谷歌地图搜索栏 [英] Xcode Google Maps Search Bar

查看:110
本文介绍了Xcode谷歌地图搜索栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个基于iPhone的位置应用程序,我在最后一个方面遇到了麻烦。我想知道是否有人知道如何整合一个与我们可以在 MKMapView 中使用的地图相关的搜索栏。

I'm making an iPhone location based app and I'm having trouble with the last aspect of it. I was wondering if anyone knows how to integrate a search bar that correlates with the map that we can use from MKMapView.

它实际上是地图上方的一个搜索栏,用户可以在某个区域输入内容,并将它们带到那里。

It's literally a search bar above the map that the user can type in an area and it will take them there.

这可能吗?

我已经四处寻找教程,但我只找到了如何使用地图视图,注释和添加标注来制作应用程序。

I've looked around for tutorials but I have only found how to make an app with a map view, annotations and adding callouts.

推荐答案

您要查找的是地理编码 - 将搜索栏中的地址转换为纬度/经度坐标,然后你可以设置地图的位置。

What you're looking for is geocoding - the process of turning an address in your search bar into a latitude/longitude coordinate, which you can then set the map's position to.

这个问题有两个主要答案。 此答案显示了如何使用Google API进行地理编码,以及此答案显示了如何使用Apple API进行地理编码。

This question has two main answers. This answer shows how to geocode using a Google API, and this answer shows how to geocode using an Apple API.

如果您使用的是MapKit 6.0),那么你应该使用Apple API(你不应该使用谷歌地图API与非谷歌地图)。

If you're using MapKit (which uses Apple maps as of iOS 6.0), then you should probably use the Apple API (you are not supposed to use Google Maps APIs with non-Google maps).

如果您使用< a href =https://developers.google.com/maps/documentation/ios/ =nofollow noreferrer>新版Google Maps SDK for iOS ,您可能需要使用Google API进行地理编码。虽然请注意,我所链接的答案是将Google API与MapKit一起使用(因为它在MapKit使用Google Maps时被写回),所以您需要稍微修改它。

If you're using the new Google Maps SDK for iOS, you might want to use the Google API for geocoding. Although note that the answer I've linked to is using the Google API with MapKit (as it was written back when MapKit was using Google Maps), so you would need to modify it a bit.

这篇关于Xcode谷歌地图搜索栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆