我这里的使用场景是校验所选经纬度是否所属于规定的省市区下面
获取区域code码进行比对
- 封装的查询类
<?php
namespace app\common\library;
/**
* @name: 经纬度查询类
* @author: Turbo
* @Date: 2022-09-20 10:44:36
*/
class SelectLngLatData
{
protected static $instance;
/**
* @var array 配置
*/
protected $option = [];
/**
* @var int 当前时间
*/
protected $time = 0;
/**
* @var string 错误信息
*/
protected $errorMessage = '';
public function __construct($lng = 0, $lat = 0)
{
$this->time = time();
$this->option['lng'] = $lng;
$this->option['lat'] = $lat;
}
private function __clone()
{
// TODO: Implement __clone() method.
}
/**
* 初始化
* @param str $lng 经度
* @param str $lat 纬度
* @return SelectLngLatData
*/
public static function instance($lng = 0, $lat = 0)
{
if (is_null