PHP code example of imphinite / gaode-maps
1. Go to this page and download the library: Download imphinite/gaode-maps 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/ */
imphinite / gaode-maps example snippets
composer
" ....,
"imphinite/gaode-maps",
},
'providers' => [
...
'GaodeMaps\ServiceProvider\GaodeMapsServiceProvider',
]
'aliases' => [
...
'GaodeMaps' => 'GaodeMaps\Facade\GaodeMapsFacade',
]
/*
|----------------------------------
| Service Keys
|------------------------------------
*/
'key' => 'YOUR GAODE API KEY HERE',
$service = GaodeMaps::load('nearbysearch')
->setParam([
'location' => '120.392164,36.056936', // Longitude first in Chinese convention
'keywords' => '餐厅',
'radius' => 5000,
'page' => 1,
'extensions' => 'all',
'output' => 'json'
]);
$response = $service->get();
...
$endpoint = GaodeMaps::load('nearbysearch')
->setParamByKey('location', '120.392164,36.056936')
->setParamByKey('keywords', '餐厅') //return $this
...
$batch_urls = array();
array_push($batch_urls, (object) array(
'url' => GaodeMaps::load('placedetails')
->setParam(['id' => $place->id)
->getBatchUrl()
)
);
$service = GaodeMaps::load('batchrequest')
->setParam([
'ops' => $batch_urls
]);
$response = $batch_service->get();
...
GaodeMaps::load('nearbysearch')
...
$service = GaodeMaps::load('nearbysearch')
->setParamByKey('location', '120.392164,36.056936')
->setParamByKey('keywords', '餐厅') //return $this
...
$service = GaodeMaps::load('nearbysearch')
->setParam([
'location' => '120.392164,36.056936', // Longitude first in Chinese convension
'keywords' => '餐厅',
'radius' => 5000,
'page' => 1,
'extensions' => 'all',
'output' => 'json'
]); // return $this
...
$url = GaodeMaps::load('nearbysearch')
->setParam([
'location' => '120.392164,36.056936', // Longitude first in Chinese convension
'keywords' => '餐厅',
'radius' => 5000,
'page' => 1,
'extensions' => 'all',
'output' => 'json'
])->getBatchUrl();
...
$response = GaodeMaps::load('nearbysearch')
->setParam([
'location' => '120.392164,36.056936', // Longitude first in Chinese convension
'keywords' => '餐厅',
'radius' => 5000,
'page' => 1,
'extensions' => 'all',
'output' => 'json'
])->get();
var_dump(json_decode($response)); // output
...
/*
{
"status": "1",
"count": "274",
"info": "OK",
"infocode": "10000",
"suggestion": {
"keywords": [],
"cities": []
},
"pois": [
"0": {
"id": "B0FFFF4RX1",
"tag": "牛道红花牛三品,菌类拼盘,新快猪上五花,牛舌厚切,石锅拌饭,红花三拼,红花牛芝士盖饭,烤蘑菇,红花牛肉,猪雪花肩胛肉,牛舌薄切,生拌牛肉,迷你现压朝鲜冷面,炒乌冬面,牛肩胛肉,酱香牛腿芯,海鲜饼,牛肋脊,泡菜饼,烤牛肉,牛仔骨,海鲜乌冬面,红花牛特色三样,烤五花肉,极品一口牛排",
"name": "新快牛道红花牛馆(百丽广场店)",
"type": "餐饮服务;中餐厅;特色/地方风味餐厅",
...
*/