Drupal 6 Location Module使用邮政编码获取城市名称

时间:2011-02-21 07:46:13

标签: php drupal-6 drupal-views drupal-modules

我正在使用位置模块并启用了位置CCK字段。在创建内容时,我只是收集邮政编码和国家/地区。我想使用与节点相关联的邮政编码显示城市名称。

我知道位置模块附带邮政编码数据库。是否需要查询此邮政编码数据库以获取城市名称?如果那个邮政编码不可用,那么什么可以解决?

请指导我如何实现这一目标?

2 个答案:

答案 0 :(得分:1)

部分内容已经解决。这可能对其他人有所帮助。 您可以通过位置模块中提供的功能获得邮政编码信息,即 location_get_postalcode_data ,它接受位置参数作为数组

@param $location
 *   Array. the location data
 *   -> the values are:
 *     'street'         => the string representing the street location (REQUIRED)
 *     'additional'     => the string representing the additional street location portion in the location form
 *     'city'           => the city name (REQUIRED)
 *     'province'       => the province code defined in the country-specific include file
 *     'country'        => the lower-case of the two-letter ISO code (REQUIRED)
 *     'postal_code'    => the postal-code (REQUIRED)

我还在支持的目录中提供了我所在国家/地区特定的 .inc 文件中的一些修改,以获取额外信息以及默认的lat-lon信息。

但是,如果邮政编码在数据库中不可用,那么第二部分则待定。

答案 1 :(得分:1)

public function 
{
    $null='';
    #   REFERENCE SITE URL = http://developer.yahoo.com/maps/rest/V1/geocode.html


    #   get and output "<Result>" elements
    $result=$xmlDoc->getElementsByTagName('Result');
    foreach ($result as $val)
    {
        return $null;
    }
}