graychen/geolocation

Get the geographic location based on latitude and longitude

v1.0.1 2017-08-25 08:04 UTC

This package is not auto-updated.

Last update: 2024-11-10 04:17:26 UTC


README

composer包 根据经纬度得到地理位置信息,暂时还只有baidu地图api接口

this is a library for find address by geolocation

Latest Stable Version Total Downloads License StyleCI Build Status Scrutinizer Code Quality Code Coverage Build Status

how to use

<?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);
    }
}