当前位置:网站首页>根據百度地图返回的地址,截取省,市,区
根據百度地图返回的地址,截取省,市,区
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;
},
边栏推荐
- 【LaTex异常与错误】 - 公式编号的参考引用命令\eqref发生错误Undefined control sequence——可能是因为没加载宏包amsmath
- (2022牛客多校五)C-Bit Transmission(思维)
- 【瑞吉外卖】day04:员工分页查询、启用/禁用员工账号、编辑员工信息
- Qt入门(五)——文件操作、热键和鼠标的读取(txt窗口的实现)
- 04 Spark on 读取外部数据分区策略(源码角度分析)
- 最详树莓派4B装机流程及ifconfig不到wlan0的解决办法
- ArrayAccess 接口用处
- (2022牛客多校四)D-Jobs (Easy Version)(三维前缀或)
- Button Wizard Delete File Command
- (2022牛客多校四)H-Wall Builder II(思维)
猜你喜欢

06 Spark on RDD序列化问题

(2022牛客多校五)H-Cutting Papers(签到)

【latex异常与错误】There were undefined references.Reference `xxx‘ on page x undefined.参考引用公式编号时发生错误

【PP-YOLOv2】训练自定义的数据集

【Bug解决】ValueError: Object arrays cannot be loaded when allow_pickle=False

Binary tree level traversal and examples

【瑞吉外卖】day04:员工分页查询、启用/禁用员工账号、编辑员工信息

(Codeforce 757)E. Bash Plays with Functions(积性函数)

使用Mongoose populate实现多表关联存储与查询,内附完整代码

07 Spark on RDD 血缘关系
随机推荐
(2022杭电多校四)1001-Link with Bracket Sequence II(区间动态规划)
Low-Light Image Enhancement via a Deep Hybrid Network阅读札记
51nod2884
微信小程序开发一些函数使用方法
小程序banner图展示
(2022牛客多校五)B-Watches(二分)
官方一键安装redis集群
Hi3516 使用 wifi模块
51nod1798 打怪兽
生成二维码容错级别的问题
PHP闭包函数 bingTo的使用
2022杭电多校六 1006-Maex (树形DP)
牛客多校2 G League of Legends
2022杭电多校六 1009-Map (巴那赫不动点)
一命令删除所有指定进程
设计分享|基于单片机的P0口驱动LED闪烁
[YOLOv5] 6.0 environment construction (updated from time to time)
用工具实现 Mock API 的整个流程
2022牛客多校六 A-Array(构造+哈夫曼)
微信小程序 wx:for 循环输出 例子