mtsung/twdd.location

台湾定位工具

1.0.5 2023-07-12 00:15 UTC

This package is auto-updated.

Last update: 2024-09-12 03:05:10 UTC


README

适用于 Laravel 6 7 8

安装

composer require mtsung/twdd.location

Lumen

bootstrap/app.php 文件

$app->register(\Mtsung\TwddLocation\TwddLocationServiceProvider::class);

使用方法

通过经纬度查询县市乡镇区

use Mtsung\TwddLocation\Facade\TwddLocation;

$res = TwddLocation::getCity(25.03375, 121.564879);
/*
array:2 [
  "city_code" => "63000"
  "city_name" => "臺北市"
]
*/

$res = TwddLocation::getDistrict(25.077741, 121.574829);
/*
array:4 [
  "city_code" => "63000"
  "city_name" => "臺北市"
  "district_code" => "63000100"
  "district_name" => "內湖區"
  "zip_code" => "114"
]
*/

$res = TwddLocation::getCity(34.92475,135.79863);
// null

$res = TwddLocation::getDistrict(39.256422, 140.986340);
// null

通过邮编或区码查询乡镇区

use Mtsung\TwddLocation\Facade\TwddDistrict;

$res = TwddDistrict::getInfoByZipCode(238);
/*
array:5 [
  "city_code" => "65000"
  "city_name" => "新北市"
  "district_code" => "65000070"
  "district_name" => "樹林區"
  "zip_code" => "238"
]
*/

$res = TwddDistrict::getInfoByZipCode(114);
/*
array:5 [
  "city_code" => "63000"
  "city_name" => "臺北市"
  "district_code" => "63000100"
  "district_name" => "內湖區"
  "zip_code" => "114"
]
*/

$res = TwddDistrict::getInfoByZipCode(9999);
// null

$res = TwddDistrict::getInfoByDistrictCode(67000300);
/*
array:5 [
  "city_code" => "67000"
  "city_name" => "臺南市"
  "district_code" => "67000300"
  "district_name" => "龍崎區"
  "zip_code" => "719"
]
*/

$res = TwddDistrict::getInfoByDistrictCode(9999);
// null

数据来源

直辖市、县市界线

乡镇市区界线

3码邮政区号

许可证

MIT 许可证