iPhone反向地理编码:提供所有可能的街道/郊区? [英] iPhone reverse geocoding: give all possible streets/suburbs?

查看:82
本文介绍了iPhone反向地理编码:提供所有可能的街道/郊区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道核心位置在iPhone上并不总是准确的。有没有办法使用位置(经度/纬度)以及精度来捕获该区域中所有可能的郊区/街道?

I know Core Location isnt always accurate on the iPhone. Is there a way to use the location (lat/long) along with the accuracy to then grab all of the possible suburbs/streets in that area?

反向地理编码并猜测可能的最佳郊区/街道,有没有办法让它给出它可能考虑的所有可能的郊区/街道的阵列(或其他格式)?

So instead of using the reverse geocoding and having it guess the 'best possible suburb/street, is there a way to make it give an array (or in some other format) of all the possible suburbs/streets that it could consider?

谢谢!

推荐答案

因此,最好的方法是使用Google地图API。例如,看看下面的网址: http ://maps.google.com/maps/geo?q = 38.4417077,-90.7122047& output = xml

So, the best approach to do this, is using the Google maps API. For example, take a look ate the following url: http://maps.google.com/maps/geo?q=38.4417077,-90.7122047&output=xml

您可以看到,为此对(纬度,经度),您有10个可能的地标。

As you can see, for this pair (latitude, longitude) you have 10 possible placemarks for this coordinates.

有关此文档的信息,请参见: http://code.google.com/apis/maps/documentation/geocoding/index.html

The documentation for this you can find at: http://code.google.com/apis/maps/documentation/geocoding/index.html

您可以看到以XML,JSON和CSV格式获取信息。

You can see that you get the info in XML, JSON, CSV.

看看状态码,因此验证请求是否成功(通常为200或200左右)非常重要。

Take a look at the status code, it is important to verify if the request was successful (usually 200 or 200 and something).

那么,如何使用VFN?

So, how to use it VFN?

很简单。



double latitude = coordinate.latitude;
    double longitude = coordinate.longitude;

    NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%f,%f&output=xml", latitude, longitude];   
    NSURL *url = [NSURL URLWithString:urlString];


    NSString *locationString = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];

是Google Geocoder的响应,现在您可以根据需要使用该信息。请记住,首先检查状态码,然后解析信息。如果只希望Google Geocoder选择的第一个地标,建议您使用CSV格式的输出,这很容易使用。

on locationString is the response from Google Geocoder, now you can use the info as you want. Remember to first check the status code, and than parse the info. If you want only the first placemark that is selected by Google Geocoder, I would suggest you to use the output in CSV, that is easy to work with.

如果任何疑问,请让我知道!

If you have any queries, let me know!

干杯,

VFN

Cheers,
VFN

这篇关于iPhone反向地理编码:提供所有可能的街道/郊区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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