使用Google API生成基于城市和州的邮政编码 [英] Generate zip code based on City and State with Google API

查看:169
本文介绍了使用Google API生成基于城市和州的邮政编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法根据表格中的城市/州输入进行邮政编码查询?我在想Google的geocode API可能是正确的方向。有什么想法吗?我有一个基于WordPress的网站,所以代码将不得不使用PHP。

解决方案

YQL可以做这样的事情:

 从geo.places.children中选择名称,其中parent_woeid in(从geo.places中选择woeid,其中text =sunnyvale,usa限制1)AND placetype = 11 

返回:

  {
query:{
count:6,
created:2011-03-16T06:49:09Z,
lang:zh-CN ,
results:{
place:[
{
name:94086
},
{
name:94087
},
{
name:94088
},
{
name: 94089

{
name:94090
},
{
name:94085
}
]
}
}
}

YQL控制台

这里有一些关于如何在 PHP Javascript 在他们的网站上。


Would there be a way to do a zip code lookup based on City/State input in a form? I'm thinking the Google geocode API might be the right direction. Any thoughts? I have a site built on Wordpress so the code would have to utilize PHP. Thanks in advance.

解决方案

YQL can do things like this:

select  name from geo.places.children where parent_woeid in (select woeid from geo.places where text="sunnyvale, usa" limit 1) AND placetype = 11

returns:

{
 "query": {
  "count": 6,
  "created": "2011-03-16T06:49:09Z",
  "lang": "en-US",
  "results": {
   "place": [
    {
     "name": "94086"
    },
    {
     "name": "94087"
    },
    {
     "name": "94088"
    },
    {
     "name": "94089"
    },
    {
     "name": "94090"
    },
    {
     "name": "94085"
    }
   ]
  }
 }
}

YQL Console

There are examples on there on how to implement queries like this in both PHP and Javascript on their site.

这篇关于使用Google API生成基于城市和州的邮政编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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