当前位置:网站首页>根據百度地图返回的地址,截取省,市,区
根據百度地图返回的地址,截取省,市,区
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;
},
边栏推荐
猜你喜欢
05 Spark on 读取内部数据分区存储策略(源码角度分析)
[Bug solution] ValueError: Object arrays cannot be loaded when allow_pickle=False
51nod 2887 抓小偷 平面图最小割转换成最短路
微信小程序 wx:for 循环输出 例子
ndk和JNI的使用初探
(2022牛客多校二)L-Link with Level Editor I(动态规划)
Introduction to Qt (5) - file operation, hotkey and mouse reading (implementation of txt window)
牛客多校2 G League of Legends
51nod 1706 最短路 + 思维
牛客练习赛88 D 克鲁斯卡尔重构树
随机推荐
LeetCode:正则表达式匹配
[Tensorflow2] Some interface changes of tensorflow1.x-tensorflow2.x
(2022牛客多校四)A-Task Computing (排序+动态规划)
最详树莓派4B装机流程及ifconfig不到wlan0的解决办法
洛谷P4197 Peaks 线段树合并
13 Spark on RDD 全局累加器
2022杭电多校六 1007-Shinobu loves trip(同余方程)
MySQL 高级知识【 MyISAM 读锁写锁限制】
WeChat applet error undefined Expecting 'STRING','NUMBER','NULL','TRUE','FALSE','{','[', got ]Solution
Casbin 进行权限控制验证
Master-slave delay reason and solution
10 Spark on RDD Cache
Kubernetes web网站无法访问
主从延迟原因及解决方案
bp神经网络的学习心得
动手写prometheus的exporter-01-Gauge(仪表盘)
考证必看 | PMP扫盲贴+PMP材料
可以在易方达基金上买基金吗,安全吗
ArrayAccess 接口用处
09 Spark on RDD 阶段划分