【问题标题】:Using Google Maps to gather company address?使用谷歌地图收集公司地址?
【发布时间】:2011-04-18 13:18:08
【问题描述】:

我有一个页面,其中 X 人写下他们的公司名称,例如:“BCF,Cannon Hill”

我想编写一个脚本,通过谷歌地图查找这家公司并返回第一个结果(地址)。

例如;他们输入"BCF, Cannon Hill"

我们的脚本返回:

1177 Wynnum Road, Cannon Hill QLD 4170, Australia

http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=bcf,+cannon+hill

我该怎么做?有没有 PHP api 什么的?

谢谢:)

【问题讨论】:

    标签: php maps


    【解决方案1】:

    虽然这违反了 google 使用条款,但您​​可以按如下方式仅删除该项目(或者,根据您的需要,Places API 可能是一个更好的解决方案:http://code.google.com/apis/maps/documentation/places/):

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <body>
    <?php
    $input=addslashes($_REQUEST["search"]);
    if(strlen($input)>0){
    $input=str_replace(" ","+",$input);
    $url="http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=".$input;
    $file=file_get_contents($url);
    $start=strpos($file,"pp-headline-item pp-headline-address")+44;
    $end=strpos($file,"</span>",$start);
    $firstResult=substr($file,$start,$end-$start);
    echo $firstResult;
    }
    else{
        echo "You must add the 'search' parameter";
    }
    ?>
    </body>
    </html>
    

    【讨论】:

      【解决方案2】:

      或者您可能需要绑定 Telstra Yellow pages 数据库来获取澳大利亚的所有商业地址?

      【讨论】:

        猜你喜欢
        • 2017-09-13
        • 2012-06-23
        • 1970-01-01
        • 2017-12-25
        • 2013-08-08
        • 2013-09-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多