composer包 根据经纬度得到地理位置信息,暂时还只有baidu地图api接口
<?php
namespace graychen\Tests;
use PHPUnit\Framework\TestCase;
use graychen\geolocation\BaiduGeolocation;
class BaiduGeolocationTest extends TestCase
{
private $geolocation;
public function setUp()
{
$this->geolocation=new BaiduGeolocation();
}
/**
* Asserts that the container can set and get a simple closure with args.
*/
public function testGetgeolocation()
{
$this->geolocation->latitude= "your latitude";
$this->geolocation->longitude= "your longitude";
$this->geolocation->ak= "your ak";
$json_content=$this->geolocation->getGeolocation();
$province=$json_content["result"]["addressComponent"]["province"];
$this->assertEquals("江苏省", $province);
}
}