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

feat: 优化门店经纬度定位

parent f2126191
...@@ -34,11 +34,9 @@ export default props => { ...@@ -34,11 +34,9 @@ export default props => {
const geocoder = new window.AMap.Geocoder({ const geocoder = new window.AMap.Geocoder({
city, city,
}); });
geocoder.getLocation(addrInfo.address, (status, result) => { geocoder.getLocation(addrInfo.address, (status, result) => {
if (status === 'complete' && result.geocodes.length) { if (status === 'complete' && result.geocodes.length) {
const { lng, lat } = result.geocodes[0].location; const { lng, lat } = result.geocodes[0].location;
console.log(result.geocodes[0].location);
setLnglat([lng, lat]); setLnglat([lng, lat]);
setLnglatText(`${lng},${lat}`); setLnglatText(`${lng},${lat}`);
} else { } else {
...@@ -73,7 +71,7 @@ export default props => { ...@@ -73,7 +71,7 @@ export default props => {
created: getPoint, created: getPoint,
click: onGetPoint, click: onGetPoint,
}} }}
zoom={15} zoom={14}
> >
<Marker position={lnglat}></Marker> <Marker position={lnglat}></Marker>
</Map> </Map>
......
...@@ -76,6 +76,22 @@ const StoreModal = props => { ...@@ -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 openMap = v => {
const values = getFieldsValue(); const values = getFieldsValue();
...@@ -96,9 +112,10 @@ const StoreModal = props => { ...@@ -96,9 +112,10 @@ const StoreModal = props => {
} }
}); });
} }
const labels = getAreas(values.addr);
setMapInfo({ setMapInfo({
provice, provice,
address: values.address, address: labels + values.address,
}); });
setVisibleMap(v); 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