PHP code example of rr-earring / baidu-map
1. Go to this page and download the library: Download rr-earring/baidu-map library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rr-earring / baidu-map example snippets
use RrEarring\BaiduMap\Factory;
$config = [
'ak' => 'your ak',
// 'sk' => 'your sk',
'log' => [
'file' => './map.log',
'name' => 'map.log',
],
'response_type' => 'array',
];
$webApi = Factory::baiduApi($config);
$result = $webApi->geocoding->get('北京市海淀区上地十街10号');
//Array
//(
// [status] => 0
// [result] => Array
//(
// [location] => Array
// (
// [lng] => 116.307887147
// [lat] => 40.0572204451
// )
//
// [precise] => 1
// [confidence] => 80
// [comprehension] => 100
// [level] => 门址
// )
//
//)