Commit f5782dde authored by baixian's avatar baixian

选点优化

parent e8c3d503
......@@ -84,38 +84,44 @@ class SelectPlaceMap extends React.Component {
that.infoArray.forEach((ele) => {
ele.setMap(null);
});
console.log(res, 'res');
showLatlng = new qq.maps.LatLng(res.result.location.lat, res.result.location.lng);
const title = res.result.address_component.province + res.result.address_component.city + res.result.formatted_addresses.rough;
dispatch({
type: 'schooladd/updateState',
payload: {
longitude: res.result.location.lng,
latitude: res.result.location.lat,
locationAddress: title,
province: res.result.address_component.province,
city: res.result.address_component.city,
district: res.result.address_component.district,
},
});
let title = '';
if (res.result.address_component.province) {
title = res.result.address_component.province + res.result.address_component.city + res.result.formatted_addresses.rough;
dispatch({
type: 'schooladd/updateState',
payload: {
longitude: res.result.location.lng,
latitude: res.result.location.lat,
locationAddress: title,
province: res.result.address_component.province,
city: res.result.address_component.city,
district: res.result.address_component.district,
},
});
}
// message.success('已将该地址导入为机构地址,不要忘记保存哦', 2);
const pointMarker = new qq.maps.Marker({
position: showLatlng,
map: that.map,
});
const info = new qq.maps.InfoWindow({
map: that.map,
content: title,
position: showLatlng,
zIndex: 99,
visible: true,
});
qq.maps.event.addListener(pointMarker, 'click', () => {
info.open();
info.setContent(title);
info.setPosition(showLatlng);
});
if (title != '') {
const info = new qq.maps.InfoWindow({
map: that.map,
content: title || '',
position: showLatlng,
zIndex: 99,
visible: true,
});
qq.maps.event.addListener(pointMarker, 'click', () => {
info.open();
info.setContent(title);
info.setPosition(showLatlng);
});
that.infoArray.push(info);
}
that.pointArray.push(pointMarker);
that.infoArray.push(info);
that.setState({
locationList: [],
});
......
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