From 83b2f9a4f48cdf810a28ce1a28591afca6d904be Mon Sep 17 00:00:00 2001 From: jinweijian Date: Fri, 15 Aug 2025 10:21:49 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E7=9A=84SDK?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ESCloudSDK.php | 9 ++++ src/Service/MapService.php | 98 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 src/Service/MapService.php diff --git a/src/ESCloudSDK.php b/src/ESCloudSDK.php index a449e37..049b798 100644 --- a/src/ESCloudSDK.php +++ b/src/ESCloudSDK.php @@ -8,6 +8,7 @@ use ESCloud\SDK\Service\DrpService; use ESCloud\SDK\Service\ESopService; use ESCloud\SDK\Service\InspectionService; +use ESCloud\SDK\Service\MapService; use ESCloud\SDK\Service\MobileService; use ESCloud\SDK\Service\MpService; use ESCloud\SDK\Service\NotificationService; @@ -189,6 +190,14 @@ public function getPlatformNewsService() return $this->getService('PlatformNews'); } + /** + * @return MapService + */ + public function getMapService() + { + return $this->getService('Map', true); + } + /** * 根据服务名获得服务实例 * diff --git a/src/Service/MapService.php b/src/Service/MapService.php new file mode 100644 index 0000000..3ecb08b --- /dev/null +++ b/src/Service/MapService.php @@ -0,0 +1,98 @@ +request('POST', '/api/v1/location/wgs84ToBd09', ['longitude' => $longitude, 'latitude' => $latitude]); + } + + /** + * 将高德/腾讯坐标转换为百度经纬度坐标 + * + * @param float $longitude + * @param float $latitude + * @return array|mixed + * @throws SDKException + * @throws \ESCloud\SDK\Exception\ResponseException + * @throws \ESCloud\SDK\HttpClient\ClientException + */ + public function gcj02ToBd09(float $longitude, float $latitude) + { + return $this->request('POST', '/api/v1/location/gcj02ToBd09', ['longitude' => $longitude, 'latitude' => $latitude]); + } + + /** + * 计算一个中心点与其他一系列坐标点的距离 + * + * @param float $longitude + * @param float $latitude + * @param array $targets + * @return array|mixed + * @throws SDKException + * @throws \ESCloud\SDK\Exception\ResponseException + * @throws \ESCloud\SDK\HttpClient\ClientException + */ + public function distances(float $longitude, float $latitude, array $targets) + { + if (empty($targets)) { + throw new SDKException('Targets is empty.'); + } + foreach ($targets as $target) { + if (empty($target) || !is_array($target) || !isset($target['longitude']) || !isset($target['latitude'])) { + throw new SDKException('Targets is invalid.'); + } + } + + return $this->request('POST', '/api/v1/location/distances', [ + 'origin' => ['longitude' => $longitude, 'latitude' => $latitude], + 'targets' => $targets, + ]); + } + + /** + * 获取地图服务状态 + * + * @return array|mixed + * @throws SDKException + * @throws \ESCloud\SDK\Exception\ResponseException + * @throws \ESCloud\SDK\HttpClient\ClientException + */ + public function status() + { + return $this->request('GET', '/api/v1/tenant/status'); + } + + /** + * 获取地图服务代理URL + * + * @return string + */ + public function proxyUrl() + { + return '//'.$this->host.'/proxy/'.$this->getProxyToken(); + } + + public function getProxyToken() + { + return str_replace('Bearer ', '', $this->auth->makeRequestAuthorization('', '', 3600, true, $this->service)); + } +} From fc0681bd7d16471a466fa744c1626571e78b36c6 Mon Sep 17 00:00:00 2001 From: jinweijian Date: Mon, 18 Aug 2025 14:43:42 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E7=9A=84=E9=BB=98=E8=AE=A4=E7=AB=99=E7=82=B9=E5=9F=9F=E5=90=8D?= =?UTF-8?q?=E6=9B=B4=E6=8D=A2=E6=88=90=E7=BA=BF=E4=B8=8A=E7=9C=9F=E5=AE=9E?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=9F=9F=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Service/MapService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Service/MapService.php b/src/Service/MapService.php index 3ecb08b..50594a6 100644 --- a/src/Service/MapService.php +++ b/src/Service/MapService.php @@ -6,7 +6,7 @@ class MapService extends BaseService { - protected $host = 'map.edusoho.cn'; + protected $host = 'map.vviioo.com'; protected $service = 'Map';