如何根据用户位置显示附近的结果? [英] How to show the nearby result as per user location ?

查看:83
本文介绍了如何根据用户位置显示附近的结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经把它作为食物的应用程序基本上我想要做的是知道我想根据用户位置显示食品商店例如



< pre lang =java> if (userlocation == RAJAPARK){
thencallThisfunction();
}

else (userlocation == XYZ){
Toast.makeText(getActivity(), 你周围没有食品店

}





但我是不能将街道名称与我的变量匹配,我没有得到任何正确的指导这样做,所以PLZ帮助我



我尝试过:



我试图获取用户街道名称并与我的变量匹配,但它不起作用

通过以下链接 - http ://javapapers.com/android/android-get-address-with-street-name-city-for-location-with-geocoding/

解决方案

也许你需要使用Google Places API Places API [ ^ ]



这是一个工作示例



使用Google Places API和Google Map Android API V2显示附近的地点知识经验 [ ^ ]



编辑:



好像通过魔术一篇文章出现 Google地图搜索附近:显示附近使用Google Places API和Google Maps API V2的地方 [ ^ ]



/ Darren


引用:

我试图获取用户街道名称并与我的变量匹配但它不起作用



使用街道名称感觉就像让事情变得复杂。

我只会使用GPS用户坐标和食品店和重新计算距离转到最近的商店。



2个GPS坐标之间的距离计算用

大圆距离 - 维基百科,免费的百科全书 [ ^ ]



为了减少距离计算的数量,您需要一种巧妙的存储方式。

- 最简单的方法是让所有商店都在一个单一的列表,不足之处,你必须每次计算到每个商店的距离。

- 你可以更有效率将地图划分为正方形并记下每个商店的正方形。一旦你知道你是哪个广场,你只需要检查附近实际广场和广场的商店。

希尔伯特曲线 - 维基百科,免费的百科全书 [ ^ ]


I had made it an app which is for food basically what I want to do is know I want to show food stores as per user location for example

 if (userlocation == "RAJAPARK") {
            thencallThisfunction();
        }

 else (userlocation == "XYZ") {
Toast.makeText(getActivity(), "There is no food store around you",

}



but i am not able to match a street name with my variable and i am not getting any proper guide for doing this so plz help me

What I have tried:

I tried to get user street name and matching with my variables but it does not work
by following this link - http://javapapers.com/android/android-get-address-with-street-name-city-for-location-with-geocoding/

解决方案

Perhaps you need to use the Google Places API Places API[^]

Here is a working example

Showing nearby places using Google Places API and Google Map Android API V2 | Knowledge by Experience[^]

EDIT:

As if by magic an article appears Google Maps Search Nearby : Displaying Nearby Places using Google Places API and Google Maps API V2[^]

/Darren


Quote:

I tried to get user street name and matching with my variables but it does not work


Using street name just feel like complicating things.
I would just use GPS user coordinates and calc distances with food shops and return only closest shops.

Distance calculation between 2 GPS coordinates is done with
Great-circle distance - Wikipedia, the free encyclopedia[^]

In order to reduce the number of distance calculations, you need a clever way of storing shops.
- The most simple way is to have all shops in a flat list, downside, you have to calculate distance to every shop every times.
- You can be more efficient by dividing the map in squares and note the square for each shop. Once you know which square you are, you just have to check shops in actual square and squares nearby.
Hilbert curve - Wikipedia, the free encyclopedia[^]


这篇关于如何根据用户位置显示附近的结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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