如果我有城镇或地区的纬度和经度坐标,我如何在Google地图中获取城市名称?
我尝试使用纬度,经度和我有国家,但我不知道如何获得城市名称.
除了谷歌地图API之外,是否有任何网络服务(付费或免费)允许您反转地理编码?
我的特定应用程序将可以访问经度和纬度,我需要能够获得美国邮政编码或州.
我无法使用Google的原因是,服务条款似乎表明,如果您使用Google Maps API,则需要使用这些数据来显示Google地图.
我正在使用C#.Net框架,以防相关.
我想基于long/lat得到一个地址.似乎这样的事情应该有效吗?
Geocoder myLocation = Geocoder(Locale.getDefault());
List myList = myLocation.getFromLocation(latPoint,lngPoint,1);
Run Code Online (Sandbox Code Playgroud)
问题是我不断得到:方法Geocoder(Locale)未定义类型savemaplocation
任何帮助都会有所帮助.谢谢.
谢谢,我尝试了上下文,首先是locale,然后失败并且正在查看其他一些构造函数(我曾经看过一个只提到locale).而不管,
它没有用,因为我仍然得到:方法Geocoder(Context,Locale)未定义类型savemaplocation
我有:import android.location.Geocoder;
我在我正在进行的网站中使用了OpenStreetMap.我用PHP开发了网站.我的要求是根据地理位置(纬度和经度)获取地址.是否有任何OpenStreetMap API可用于获取基于Lat/Lon的位置信息?
谢谢,Vishal Parmar
有没有人知道我可以调用任何开放的RESTful API来将用户的IP地理编码为纬度和经度?
理想情况下,它将类似于:http://google.com/geocode_api/? IP = 1.2.3.4,它将返回纬度和经度.
对于iPhone应用程序,我需要在启动时确定用户所在的国家/地区.据推测,我将不得不打开位置服务并进行某种反向地理编码.如果可能的话,我真的不想使用第三方网络服务,是否有任何其他建议来确定服务提供的位置?
最初,我只需要检查用户是否在美国境内,但是将来可能会更改以添加更多国家/地区.我知道无法始终确定位置或用户可能已关闭位置服务.基本上,我只需要知道用户是否被检测到是在美国境内,以便关闭特定功能.
编辑:进一步阅读,它看起来像MKReverseGeocoder,除了我不希望在我的应用程序中显示任何地图,这意味着我不允许使用它.
GMSReverseGeocodeResponse 包含
- (GMSReverseGeocodeResult *)firstResult;
Run Code Online (Sandbox Code Playgroud)
其定义如下:
@interface GMSReverseGeocodeResult : NSObject<NSCopying>
/** Returns the first line of the address. */
- (NSString *)addressLine1;
/** Returns the second line of the address. */
- (NSString *)addressLine2;
@end
Run Code Online (Sandbox Code Playgroud)
有没有办法从这两个字符串中获取国家,ISO国家代码,州(administrative_area_1或相应的一个)(对所有国家和所有地址都有效)?
注意:我试图执行这段代码
[[GMSGeocoder geocoder] reverseGeocodeCoordinate:CLLocationCoordinate2DMake(40.4375, -3.6818) completionHandler:^(GMSReverseGeocodeResponse *resp, NSError *error)
{
NSLog( @"Error is %@", error) ;
NSLog( @"%@" , resp.firstResult.addressLine1 ) ;
NSLog( @"%@" , resp.firstResult.addressLine2 ) ;
} ] ;
Run Code Online (Sandbox Code Playgroud)
但由于某种原因,处理程序从未被调用过.我确实添加了应用密钥,并且还将iOS捆绑包ID添加到了应用密钥.控制台中未打印错误.有了这个,我的意思是我不知道线条的内容.
我的输入是纬度和经度.我需要使用reverseGeocodeLocationswift 的功能,给我一个本地的输出.我尝试使用的代码是
println(geopoint.longitude)
println(geopoint.latitude)
var manager : CLLocationManager!
var longitude :CLLocationDegrees = geopoint.longitude
var latitude :CLLocationDegrees = geopoint.latitude
var location: CLLocationCoordinate2D = CLLocationCoordinate2DMake(latitude, longitude)
println(location)
CLGeocoder().reverseGeocodeLocation(manager.location, completionHandler: {(placemarks, error) -> Void in
println(manager.location)
if error != nil {
println("Reverse geocoder failed with error" + error.localizedDescription)
return
}
if placemarks.count > 0 {
let pm = placemarks[0] as CLPlacemark
println(pm.locality)
}
else {
println("Problem with the data received from geocoder")
}
Run Code Online (Sandbox Code Playgroud)
在我得到的日志中
//-122.0312186
//37.33233141
//C.CLLocationCoordinate2D
//fatal error: unexpectedly found …Run Code Online (Sandbox Code Playgroud) 我试图使用Swift 3中的CLGeocoder生成格式化的完整地址.我引用了这个SO线程来获取下面给出的代码.
但是,有时应用程序崩溃时会出现"nil"错误:
//Address dictionary
print(placeMark.addressDictionary ?? "")
Run Code Online (Sandbox Code Playgroud)
问题:
完整代码:
func getAddress() -> String {
var address: String = ""
let geoCoder = CLGeocoder()
let location = CLLocation(latitude: selectedLat, longitude: selectedLon)
//selectedLat and selectedLon are double values set by the app in a previous process
geoCoder.reverseGeocodeLocation(location, completionHandler: { (placemarks, error) -> Void in
// Place details
var placeMark: CLPlacemark!
placeMark = placemarks?[0]
// Address dictionary
//print(placeMark.addressDictionary ?? "")
// Location name
if let locationName = placeMark.addressDictionary!["Name"] …Run Code Online (Sandbox Code Playgroud) 是否有一种简单的方法可以获得特定点所在国家/地区的名称?
我不太关心准确性,也不关心政治争议带来的模棱两可.只需要一个足够好的近似值.
ios ×3
android ×2
geolocation ×2
google-maps ×2
swift ×2
geocoding ×1
gis ×1
ip-address ×1
iphone ×1
xcode ×1