mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
同步腾讯地图的行政区域
This commit is contained in:
parent
b448caac61
commit
d03c01cac3
File diff suppressed because it is too large
Load Diff
@ -1,16 +1,44 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
header('content-type:application/json');
|
||||||
|
|
||||||
|
$items = [];
|
||||||
|
$url = 'https://apis.map.qq.com/ws/district/v1/list?key=AVDBZ-VXMC6-VD2SU-M7DX2-TGSV7-WVF3U';
|
||||||
|
$result = json_decode(file_get_contents($url), true)['result'];
|
||||||
|
|
||||||
|
foreach ($result[0] as $pro) {
|
||||||
|
$items[$pro['id']] = ['name' => $pro['fullname'], 'list' => []];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($result[1] as $city) {
|
||||||
|
$pkey = substr($city['id'], 0, 2) . '0000';
|
||||||
|
if (substr($city['id'], 4, 2) > 0) {
|
||||||
|
$ckey = substr($city['id'], 0, 4) . '00';
|
||||||
|
$items[$pkey]['list'][$ckey]['name'] = $items[$pkey]['name'];
|
||||||
|
$items[$pkey]['list'][$ckey]['list'][$city['id']] = ['name' => $city['fullname'], 'list' => []];
|
||||||
|
} else {
|
||||||
|
$items[$pkey]['list'][$city['id']] = ['name' => $city['fullname'], 'list' => []];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($result[2] as $area) {
|
||||||
|
$ckey = substr($area['id'], 0, 4) . '00';
|
||||||
|
$pkey = substr($area['id'], 0, 2) . '0000';
|
||||||
|
$items[$pkey]['list'][$ckey]['list'][$area['id']] = ['name' => $area['fullname'], 'list' => []];
|
||||||
|
}
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
$list = json_decode(file_get_contents(__DIR__ . '/area.json'), true);
|
foreach ($items as $citys) {
|
||||||
foreach ($list as $citys) {
|
|
||||||
$lines = [];
|
$lines = [];
|
||||||
foreach ($citys['list'] as $area) {
|
foreach ($citys['list'] as $area) {
|
||||||
$lines[] = $area['name'] . ',' . join(',', $area['list']);
|
$lines[] = $area['name'] . ',' . join(',', array_column($area['list'], 'name'));
|
||||||
}
|
}
|
||||||
$data[] = $citys['name'] . '$' . join('|', $lines);
|
$data[] = $citys['name'] . '$' . join('|', $lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
$filename = dirname(__DIR__) . '/pcasunzips.js';
|
$filename = dirname(__DIR__) . '/pcasunzips.js';
|
||||||
$content = str_replace('__STRING__', join('#', $data), file_get_contents(__DIR__ . '/area.js'));
|
$content = str_replace('__STRING__', join('#', $data), file_get_contents(__DIR__ . '/area.js'));
|
||||||
|
|
||||||
if (file_put_contents($filename, $content)) {
|
if (file_put_contents($filename, $content)) {
|
||||||
echo 'success';
|
echo 'success';
|
||||||
} else {
|
} else {
|
||||||
|
2
public/static/plugs/jquery/pcasunzips.js
vendored
2
public/static/plugs/jquery/pcasunzips.js
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user