yoozi/lbs

This package is abandoned and no longer maintained. No replacement package was suggested.

百度 LBS WEB 服务 API 的 PHP 封装实现.

1.0.8 2014-10-27 18:13 UTC

This package is not auto-updated.

Last update: 2023-05-13 08:51:24 UTC


README

Build Status

This library is part of Project Golem, see yoozi/golem for more info.

本 LBS 库是百度地图 LBS WEB API 的简单 PHP 封装。目前支持如下几个 API:

Installation

The best and easy way to install the Golem package is with Composer.

  1. Open your composer.json and add the following to the require array:

    "yoozi/lbs": "1.0.*"
    
  2. Run Composer to install or update the new package dependencies.

    php composer install
    

    or

    php composer update
    

Usage Example

以下使用 Place Suggestion API 查询关键词为 广州市 尚德大厦 地标信息:

<?php

use Yoozi\LBS\Query\Place;
use Yoozi\LBS\Search;

$place = new Place;
$place->set('method', 'suggestion');
$place->set('q', '尚德大厦');
$place->set('region', '广州市');

$search = new Search('E4805d16520de693a3fe707cdc962045', $place);

var_dump($search->run()->toArray());

Data returned:

array(3) {
  ["status"]=>
  int(0)
  ["message"]=>
  string(2) "ok"
  ["result"]=>
  array(4) {
    [0]=>
    array(5) {
      ["name"]=>
      string(12) "尚德大厦"
      ["city"]=>
      string(9) "广州市"
      ["district"]=>
      string(9) "天河区"
      ["business"]=>
      string(0) ""
      ["cityid"]=>
      string(3) "257"
    }
    [1]=>
    array(5) {
      ["name"]=>
      string(16) "尚德大厦a座"
      ["city"]=>
      string(0) ""
      ["district"]=>
      string(0) ""
      ["business"]=>
      string(0) ""
      ["cityid"]=>
      string(1) "0"
    }
    [2]=>
    array(5) {
      ["name"]=>
      string(22) "尚德大厦-停车场"
      ["city"]=>
      string(9) "广州市"
      ["district"]=>
      string(9) "天河区"
      ["business"]=>
      string(0) ""
      ["cityid"]=>
      string(3) "257"
    }
    [3]=>
    array(5) {
      ["name"]=>
      string(18) "西安尚德大厦"
      ["city"]=>
      string(9) "西安市"
      ["district"]=>
      string(9) "新城区"
      ["business"]=>
      string(0) ""
      ["cityid"]=>
      string(3) "233"
    }
  }
}