Android:如何在 MapView 上执行附近搜索
假设用户在第一步中从下拉列表中选择“星巴克”,现在我想显示一个 MapView 并列出用户位置周围的所有星巴克(我已经知道)。现在,有没有什么方法可以将“starbucks”传递给适当的组件(Geocoder
?)以启动搜索而无需任何用户交互?
我找不到任何教程或示例代码,因此如何解决它(如果可能的话)的方法将受到高度赞赏。
Let's say the user selects "Starbucks" from a dropdown list in the first step, now i want to show a MapView and list all Starbucks around user's location (which i already know). Now, is there any way to pass that "starbucks" to the appropriate component (Geocoder
?) to start a search without any user interaction?
I could't find any tutorial or sample code so an approach how to solve it (if possible at all) will be highly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那么您需要根据您的位置和项目位置之间的距离在地图上手动绘制 itemOverlays 。您可以使用位置对象的 distanceBetween 方法轻松获得该位置。假设您知道如何在地图上绘制叠加层,那么剩下的唯一事情就是获取由名称和位置组成的源(可以是本地数据库、网络服务、地理编码器等)。
这就是过程,现在关于数据源,尝试找到一些您可以使用的在线地理编码器,或者 android sdk 中有一个实际上是谷歌地图地理编码器,我上次检查的文档确实很少,但如果您足够努力的话让它发挥作用,这当然是好的。
至少从地理编码器或反向地理编码器(一个是坐标到地址,另一个是地址到坐标)中,您会获得与您的搜索相匹配的位置列表,因此请检查该列表并在地图上显示相应的位置。
Google API
仅供参考,Google 地图地理编码器是在SDK中,
Cloudmade 也有一个 api,您可以访问它进行地理编码,但没有免费的 sdk 可供使用,因此您需要自己解析内容,
Cloudmade
还有 yahoo 地图地理编码器 api,您也可以使用它。
雅虎
据我所知。
well you need to manually draw the itemOverlays on the map based on the distance between your location and the item's location. you can get that one easely with the location object's distanceBetween method. assuming you know how to draw overlays on the map the only thing left would be to get a source consisted of names and locations (can be a local database, webservice, geocoder etc).
thats the process, now about the datasource, try to find some online geocoder that you can use or there is one in the android sdk that is actually the google maps geocoder which last time i checked was really poorly documented but if you try hard enough to make it work it is certanly good.
At least from the geocoder or reverseGeocoder (the one is coordinates to address, the other one address to coordinates) you get a list of locations matching your search, so check that one and show the appropriate locations on the map.
Google API
Just for a reference there is the Google maps geocoder which is in the sdk,
there is Cloudmade which also has an api you can access for geocoding, but no free sdk for use so you will need to parse things yourself,
Cloudmade
there is also the yahoo maps geocoder api which you can also use for this.
Yahoo
that's as far as i know.