我使用 google maps static api 在我的网站上显示 map 并使用以下 url:
http://maps.googleapis.com/maps/api/staticmap?center=usa&size=800x300&maptype=roadmap&sensor=false&markers=color:blue|label:S|usa
但是,如果输入一个不存在的地址,google 会返回这样的图片:
http://maps.googleapis.com/maps/api/staticmap?center=notexistingaddress&size=800x300&maptype=roadmap&sensor=false&markers=color:blue|label:S|notexistingaddress
我想知道,如何使用 google maps static api 确定地址是否存在。我不能使用 javascript,因为这段代码是在服务器上执行的。
最佳答案
看完docs ,我认为 Google Maps Static API 没有任何东西(除了我建议的方式,例如手动验证图片的返回或仅关键字 notexistingaddress
)来验证地址存在与否。
我认为最好的验证方式是 Google Geocoding API ,您可以在其中输出给定地址的 Json/XML。 ZERO_RESULTS
的状态代码表示地理编码成功但未返回任何结果您可能会感兴趣。
https://stackoverflow.com/questions/16792448/