24 lines
1.1 KiB
JavaScript
24 lines
1.1 KiB
JavaScript
async function getExpresswayServiceAreaAddress(location_name) {
|
|
fetch('https://restapi.amap.com/v3/geocode/geo?key=53a92850ca00d7f77aef3297effd8d59&s=rsv3&jscode=220df7c191b808547be3626cbaa9d2bf&callback=&platform=JS&logversion=2.0&appname=http%3A%2F%2F192.168.2.221%3A8088%2Fwui%2Findex.html%23%2Fmain%2Fcube%2Fsearch&csid=AE54D9C0-AC7B-469C-BB7F-F677AFB04F05&sdkversion=1.4.27&address=' + location_name)
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.info == "OK") {
|
|
let res = data.geocodes.find(e => e.province == "广东省" && e.level == "道路");
|
|
if (res != undefined) {
|
|
return (res.district);
|
|
} else {
|
|
res = data.geocodes.find(e => e.province == "广东省");
|
|
if (res != undefined) {
|
|
return (res.district);
|
|
} else {
|
|
return ("no matched");
|
|
}
|
|
}
|
|
} else {
|
|
return ("no matched");
|
|
}
|
|
})
|
|
.catch(error => {
|
|
console.error('Error:', error);
|
|
});
|
|
} |