Commit 70bfa8b4 authored by 武广's avatar 武广

feat: 优化门店经纬度定位

parent f2126191
......@@ -34,11 +34,9 @@ export default props => {
const geocoder = new window.AMap.Geocoder({
city,
});
geocoder.getLocation(addrInfo.address, (status, result) => {
if (status === 'complete' && result.geocodes.length) {
const { lng, lat } = result.geocodes[0].location;
console.log(result.geocodes[0].location);
setLnglat([lng, lat]);
setLnglatText(`${lng},${lat}`);
} else {
......@@ -73,7 +71,7 @@ export default props => {
created: getPoint,
click: onGetPoint,
}}
zoom={15}
zoom={14}
>
<Marker position={lnglat}></Marker>
</Map>
......
......@@ -76,6 +76,22 @@ const StoreModal = props => {
});
};
const getAreas = arr => {
let areas = areaAddr;
let addr = '';
arr.forEach(c => {
let index = 0;
areas.forEach((item, i) => {
if (item.value === c) {
addr += item.label;
index = i;
}
});
areas = areas[index].children;
});
return addr;
};
// 显示地图
const openMap = v => {
const values = getFieldsValue();
......@@ -96,9 +112,10 @@ const StoreModal = props => {
}
});
}
const labels = getAreas(values.addr);
setMapInfo({
provice,
address: values.address,
address: labels + values.address,
});
setVisibleMap(v);
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment