每当googlemaps视口中心发生变化时,我都会尝试使用邮政编码向我的数据库提交查询.我知道这可以通过反向地理编码完成,例如:
google.maps.event.addListener(map, 'center_changed', function(){
newCenter();
});
...
function newCenter(){
var newc = map.getCenter();
geocoder.geocode({'latLng': newc}, function(results, status){
if (status == google.maps.GeocoderStatus.OK) {
var newzip = results[0].address_components['postal_code'];
}
});
};
Run Code Online (Sandbox Code Playgroud)
当然,这段代码实际上并不起作用.所以我想知道如何更改这个以便从结果数组中提取邮政编码.谢谢
google-maps geocoding postal-code reverse-geocoding google-maps-api-3
如何实现以下内容:
我知道如何:
1.找到lat/long的地址
2.绘制多边形
因此,要完成任务,我需要从地址获取构建的多边形坐标.如何?
我正在服务器端使用地理编码API来翻译latlng中的地址.我面临OVER_QUERY_LIMIT状态,即使: - 服务器没有超过2500限制(这一天只有几个请求) - 它没有同时做很多请求(一次只有一个请求)
怎么可能?第二天地理编码运行良好,但我担心我的应用程序长期正常工作.
提前致谢.
我正在使用google geocode api使用新加坡的邮政编码来获取lat
我试过以下来获取数据:
(1)http://maps.googleapis.com/maps/api/geocode/json?address=505468&sensor=false
(2)http://maps.googleapis.com/maps/api/geocode/json?address=Singapore%20505468&sensor=false
(3)http://maps.googleapis.com/maps/api/geocode/json?address=Singapore%20505468&sensor=false®ion=sg
但它从印度返回位置
https://developers.google.com/maps/documentation/geocoding/?hl=fr#RegionCodes
任何其他方式只获得特定国家(新加坡)的结果.
我试过跟着它返回正确的结果
http://maps.googleapis.com/maps/api/geocode/json?address=Singapore%20133224&sensor=false
我想自动填写用户的地址,与google api在此链接中提供的地址相同:
https://developers.google.com/maps/documentation/javascript/places-autocomplete?hl=en
如何使用Apple地图套件实现相同的功能?
我试过使用Geo Coder,我写了这个例子:
@IBAction func SubmitGeoCode(sender: AnyObject) {
let address = "1 Mart"
let coder = CLGeocoder()
coder.geocodeAddressString(address) { (placemarks, error) -> Void in
for placemark in placemarks! {
let lines = placemark.addressDictionary?["FormattedAddressLines"] as? [String]
for addressline in lines! {
print(addressline)
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
然而,结果非常令人失望.
任何可用于实现此类功能的Apple API,或者我应该使用google api?
谢谢
我需要为每个请求对200个地址进行地理编码,每天执行大约3,000个请求.我将使用PHP来做这个服务器端.我看过如何将地址转换为纬度/经度?,但找不到谷歌地图HTTP请求API或雅虎地理编码REST API(不能使用JavaScript,因为这是服务器端)发送多个地址的方法.
我将主要使用它来根据坐标对地址进行排序,如果API支持,请填写每个地址的任何缺失数据.地址仅限于美国.地理编码的地址将来自用户输入,因此可以是自由形式,如"街道地址,邮政编码"或"城市,州"等.准确性对于坐标来说并不重要,例如在500英尺左右.
是否有免费的API来处理这个问题?有没有办法让雅虎或谷歌在请求中执行多个位置?
当我使用下面的代码警告空值时?这是为什么?
HTML
<body onload="initialize()">
<div id="map_canvas" style="width: 320px; height: 480px;"></div>
<div>
<input id="address" type="textbox" value="Sydney, NSW">
<input type="button" value="Encode" onclick="display()">
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
JavaScript的
var geocoder;
var map;
function initialize() {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}
function codeAddress() {
var address = document.getElementById("address").value;
var loc=[];
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
loc[0]=results[0].geometry.location.lat();
loc[1]=results[0].geometry.location.lng(); …Run Code Online (Sandbox Code Playgroud) 我正在尝试找到一个网络服务,这将允许我获得特定Lat/Long的县名(而不是国家/地区).我将在服务器应用程序(可能是Java应用程序)中执行查找.如果我想有一些库,它没有一个web服务,但我想要最新的信息.我已经看了很多支持这个的API,但到目前为止我还没找到一个有效的API.我尝试过像这样的Yahoo API:
http://where.yahooapis.com/geocode?q=39.76144296429947,%20-104.8011589050293
但它没有填充地址信息.我试过一些"旗帜"选项也无济于事.
我也浏览了Googles API,但我读过很多他们没有填充县的地方.
那么有没有人知道任何带Lat/Long并返回与该位置相关联的县的API?如果你有任何例子,这将是伟大的.
我还想知道哪些API允许在商业应用程序中使用.我发现的很多数据都说你不能用数据来赚钱.我可能正在阅读那些错误,但我正在寻找建立一个我可能会收取使用这些数据的服务.所以我需要选择.也许是免费服务,而我正在探索各种选择,并在未来支付服务.
我一直在尝试使用一些ajax来保存我的应用程序中的场所位置,并在堆栈溢出时偶然发现以下代码
function getLatLong(address)
{
var geocoder = new google.maps.Geocoder();
var result = "";
geocoder.geocode( { 'address': address, 'region': 'uk' }, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
result[lat] = results[0].geometry.location.Pa;
result[lng] = results[0].geometry.location.Qa;
} else {
result = "Unable to find address: " + status;
}
});
return result;
}
Run Code Online (Sandbox Code Playgroud)
我的问题是当我调用函数时它什么也没有返回,当我调试并在chrome中设置断点时,它会在返回结果之前先破坏结果[lat] = results [0] .geometry.location.Pa;
我知道数组应该声明为类型数组,但即使我刚刚返回结果[0] .geometry.location对象也没有被返回
我该怎么做才能返回lat/long的位置,以便我可以存储在我的数据库中?
我正在为我的项目使用ruby geocoder gem,随着项目的不断发展,我开始考虑连接到Google API密钥.将此添加到项目后:
Geocoder.configure do |config|
# geocoding service (see below for supported options):
config.lookup = :google
# to use an API key:
config.api_key = 'my_key'
# geocoding service request timeout, in seconds (default 3):
config.timeout = 5
end
Run Code Online (Sandbox Code Playgroud)
我收到Google Geocoding API错误:请求被拒绝.当我启动应用程序时.从阅读开始,如果他们选择继续使用宝石,似乎其他人转向雅虎.我可以将gem配置为使用google api密钥吗?主要是,我想留意每日查询的数量,以避免超过限制.
geocoding ×10
google-maps ×6
geolocation ×2
javascript ×2
ios ×1
jquery ×1
postal-code ×1
swift ×1
yahoo-maps ×1