给定GPS坐标,我如何找到附近的地标或兴趣点?

时间:2020-12-14 11:31:11

I just bought a Google Nexus One smartphone, and I want to write a small Android application for fun. Suppose I can get my current GPS coordinates, so then how can I programmatically find nearby landmarks or points-of-interest within some radius? Is there an API to get GPS geo-tagged landmarks, like in Google Earth's database?

我刚买了一部谷歌Nexus One智能手机,我想写一个小的Android应用程序。假设我可以得到当前的GPS坐标,那么我如何以编程的方式在某个半径内找到附近的地标或兴趣点呢?是否有一个API来获取GPS地理标记的地标,比如谷歌地球数据库?

For example, if I'm in downtown Chicago, my program would point me to all the "tourist" things to visit in that city.

例如,如果我在芝加哥市中心,我的项目会告诉我去那个城市的所有“旅游”项目。

Ideally, it would all run on my smartphone, but if necessary, I can have the smartphone query a webserver, which would then run more queries.

理想情况下,它会在我的智能手机上运行,但如果有必要,我可以让智能手机查询一个webserver,然后运行更多的查询。

5 个解决方案

#1


4  

Depends where you're getting your landmark data from. If you want to do a web query, you could run with one of the things above.

这取决于你的地标数据来自哪里。如果您想要执行web查询,您可以使用上面的内容之一来运行。

Alternatively - if you have your own data, you can stash it in the db with lat and lon values and then form bounding rectangle for a query. This Question tells you how to calculate a bounding box that covers a given radius around your current point (it will be a box, so it will be bigger than a circle....

或者——如果您有自己的数据,您可以将它隐藏在带有lat和lon值的db中,然后为查询形成包围矩形。这个问题告诉你如何计算一个边界框覆盖给定半径在你当前的点(这将是一个盒子,所以它会比一个圆....

How to calculate the bounding box for a given lat/lng location?

如何计算给定lat/lng位置的边界框?

Using the bounding box, you can now do a query from your db where lat < maxlat and lat > minlat and lon > minlon and lon < maxlon which will give you all your points of interest within the box.

使用边界框,您现在可以在您的db中执行一个查询,其中lat < maxlat和lat > minlat和lon > minlon和lon < maxlon,它将提供您在该框内的所有兴趣点。

Then, using the Location class in the Android api, you can get it to calculate the bearing and distance to each of the hits and then you could for instance, sort by radius from your position.

然后,使用Android api中的Location类,你可以让它计算到每个命中点的方位和距离,然后你可以,例如,根据你的位置排序。

#2


2  

The quickest way to do this is:

最快的方法是:

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=business+near+city");
startActivity(intent);

After geo you put your coordinates, and after q= you input your search tearms, like tourism+city. This will fire up the Google Maps app with the points of interest.

geo之后输入坐标,q=后输入搜索tearms,比如tourism+city。这将激活谷歌地图应用程序的兴趣点。

If you want to use a maps view inside your application, you would need to get the data from some service, like your own. However you could pull the data from Google's ajax search like this: http://ajax.googleapis.com/ajax/services/search/local?v=1.0&rsz=large&gl=pl&q=tourism+chicago More info here: http://code.google.com/apis/ajaxsearch/documentation/reference.html#_fonje_local This will give you results that have geo-coordinates and you would need to make a way of parsing the results and maybe get them into a database.

如果希望在应用程序中使用maps视图,则需要从某些服务(如您自己的服务)获取数据。但是,您可以从谷歌的ajax搜索中提取数据如下:http://ajax.googleapis.com/ajax/services/search/local?

#3


1  

Another web service you might look at is: http://developer.yahoo.com/geo/geoplanet/

您可能会看到的另一个web服务是:http://developer.yahoo.com/geo/geoplanet/。

#4


1  

One developer-friendly data source you can use is http://compass.webservius.com - it's a database of millions of business listings in the USA, easily searchable with a coordinate bounding box using a REST API.

您可以使用的一个开发人员友好的数据源是http://compass.webservius.com——它是美国数以百万计的商业清单数据库,可以使用一个坐标包围框使用REST API轻松搜索。

#5


1  

Foursquare has a great API that gives you businesses and other places of interest given GPS coordinates. Doesn't require user sign in to access. The backing database is constantly maintained by foursquare users.

Foursquare有一个很好的API,可以在GPS坐标下为你提供商业和其他感兴趣的地方。不需要用户登录进入。支持数据库一直由foursquare用户维护。

https://developer.foursquare.com/overview/venues

https://developer.foursquare.com/overview/venues

#1


4  

Depends where you're getting your landmark data from. If you want to do a web query, you could run with one of the things above.

这取决于你的地标数据来自哪里。如果您想要执行web查询,您可以使用上面的内容之一来运行。

Alternatively - if you have your own data, you can stash it in the db with lat and lon values and then form bounding rectangle for a query. This Question tells you how to calculate a bounding box that covers a given radius around your current point (it will be a box, so it will be bigger than a circle....

或者——如果您有自己的数据,您可以将它隐藏在带有lat和lon值的db中,然后为查询形成包围矩形。这个问题告诉你如何计算一个边界框覆盖给定半径在你当前的点(这将是一个盒子,所以它会比一个圆....

How to calculate the bounding box for a given lat/lng location?

如何计算给定lat/lng位置的边界框?

Using the bounding box, you can now do a query from your db where lat < maxlat and lat > minlat and lon > minlon and lon < maxlon which will give you all your points of interest within the box.

使用边界框,您现在可以在您的db中执行一个查询,其中lat < maxlat和lat > minlat和lon > minlon和lon < maxlon,它将提供您在该框内的所有兴趣点。

Then, using the Location class in the Android api, you can get it to calculate the bearing and distance to each of the hits and then you could for instance, sort by radius from your position.

然后,使用Android api中的Location类,你可以让它计算到每个命中点的方位和距离,然后你可以,例如,根据你的位置排序。

#2


2  

The quickest way to do this is:

最快的方法是:

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=business+near+city");
startActivity(intent);

After geo you put your coordinates, and after q= you input your search tearms, like tourism+city. This will fire up the Google Maps app with the points of interest.

geo之后输入坐标,q=后输入搜索tearms,比如tourism+city。这将激活谷歌地图应用程序的兴趣点。

If you want to use a maps view inside your application, you would need to get the data from some service, like your own. However you could pull the data from Google's ajax search like this: http://ajax.googleapis.com/ajax/services/search/local?v=1.0&rsz=large&gl=pl&q=tourism+chicago More info here: http://code.google.com/apis/ajaxsearch/documentation/reference.html#_fonje_local This will give you results that have geo-coordinates and you would need to make a way of parsing the results and maybe get them into a database.

如果希望在应用程序中使用maps视图,则需要从某些服务(如您自己的服务)获取数据。但是,您可以从谷歌的ajax搜索中提取数据如下:http://ajax.googleapis.com/ajax/services/search/local?

#3


1  

Another web service you might look at is: http://developer.yahoo.com/geo/geoplanet/

您可能会看到的另一个web服务是:http://developer.yahoo.com/geo/geoplanet/。

#4


1  

One developer-friendly data source you can use is http://compass.webservius.com - it's a database of millions of business listings in the USA, easily searchable with a coordinate bounding box using a REST API.

您可以使用的一个开发人员友好的数据源是http://compass.webservius.com——它是美国数以百万计的商业清单数据库,可以使用一个坐标包围框使用REST API轻松搜索。

#5


1  

Foursquare has a great API that gives you businesses and other places of interest given GPS coordinates. Doesn't require user sign in to access. The backing database is constantly maintained by foursquare users.

Foursquare有一个很好的API,可以在GPS坐标下为你提供商业和其他感兴趣的地方。不需要用户登录进入。支持数据库一直由foursquare用户维护。

https://developer.foursquare.com/overview/venues

https://developer.foursquare.com/overview/venues