当前位置:网站首页>根據百度地图返回的地址,截取省,市,区
根據百度地图返回的地址,截取省,市,区
2022-08-08 23:32:00 【聰籽】
var address = '广东省广州市越秀区吉祥路'
getArea(address);
getArea: function (str) {
let area = {}
let index11 = 0
let index1 = str.indexOf("省")
if (index1 == -1) {
index11 = str.indexOf("自治区")
if (index11 != -1) {
area.Province = str.substring(0, index11 + 3)
} else {
area.Province = str.substring(0, 0)
}
} else {
area.Province = str.substring(0, index1 + 1)
}
let index2 = str.indexOf("市")
if (index11 == -1) {
area.City = str.substring(index11 + 1, index2 + 1)
} else {
if (index11 == 0) {
area.City = str.substring(index1 + 1, index2 + 1)
} else {
area.City = str.substring(index11 + 3, index2 + 1)
}
}
let index3 = str.lastIndexOf("区")
if (index3 == -1) {
index3 = str.indexOf("县")
area.Country = str.substring(index2 + 1, index3 + 1)
} else {
area.Country = str.substring(index2 + 1, index3 + 1)
}
return area;
},
边栏推荐
- (2022牛客多校四)K-NIO‘s Sword(思维)
- (Codeforce 757)E. Bash Plays with Functions(积性函数)
- moved异常,ask重定向
- (2022杭电多校六)1010-Planar graph(最小生成树)
- Button Wizard Delete File Command
- 【LaTex异常与错误】 - 公式编号的参考引用命令\eqref发生错误Undefined control sequence——可能是因为没加载宏包amsmath
- 【PP-YOLOv2】测试自定义的数据集
- 06 Spark on RDD序列化问题
- 2022牛客多校六 M-Z-Game on grid(动态规划)
- (2022牛客多校四)A-Task Computing (排序+动态规划)
猜你喜欢

2022牛客多校六 M-Z-Game on grid(动态规划)

Virtual router redundancy protocol VRRP - double-machine hot backup

【latex异常与错误】There were undefined references.Reference `xxx‘ on page x undefined.参考引用公式编号时发生错误
![WeChat applet error undefined Expecting 'STRING','NUMBER','NULL','TRUE','FALSE','{','[', got ]Solution](/img/31/a9b0c31f648d41e300949ac43c5cab.png)
WeChat applet error undefined Expecting 'STRING','NUMBER','NULL','TRUE','FALSE','{','[', got ]Solution

Manacher(求解最长回文子串)

用工具实现 Mock API 的整个流程

树莓派wiringPi库的使用补充

51nod1798 打怪兽

【CUDA】版本自由切换

ViewOverlay与ViewGroupOverlay
随机推荐
(newcoder 15079)无关(容斥原理)
(2022牛客多校五)H-Cutting Papers(签到)
2022杭电多校五 C - Slipper (dijkstra+虚拟结点)
(2022杭电多校六)1012-Loop(单调栈+思维)
循环神经网络实现股票预测
机器学习之知识点(一)
树莓派wiringPi库的使用补充
[YOLOv5] 6.0 environment construction (updated from time to time)
(2022牛客多校五)D-Birds in the tree(树形DP)
2022牛客多校六 J-Number Game(简单推理)
PHP闭包函数 bingTo的使用
51nod2884
【Verilog基础】PPA优化问题总结(含面积优化、速度优化)
Casbin 进行权限控制验证
redis集群三主三从redis-cli
bp神经网络的学习心得
[PP-YOLOv2] Training a custom dataset
抽象内部类
51nod2614 小B爱旅行 (参考范艺杰代码 基本抄袭 太难了)
51nod2861 2-sat