Commit cb9d5a48 authored by baixian's avatar baixian

地图优化1

parent da6b0e01
......@@ -86,7 +86,7 @@ export default {
longitude: Number(schoolDetailData.data.longitude),
latitude: Number(schoolDetailData.data.latitude),
locationAddress: schoolDetailData.data.location_address,
address: '',
address: schoolDetailData.data.address,
mobile: mobile || [''],
province: schoolDetailData.data.province,
city: schoolDetailData.data.city,
......@@ -194,7 +194,7 @@ export default {
title,
longitude,
latitude,
location_address: locationAddress,
location_address: province + city + district + locationAddress,
address: locationAddress,
logo: '',
category: selectcategorys.join(','),
......@@ -228,7 +228,7 @@ export default {
title,
longitude,
latitude,
location_address: locationAddress,
location_address: province + city + district + locationAddress,
address: locationAddress,
logo: '',
category: selectcategorys.join(','),
......
......@@ -11,7 +11,6 @@ class SelectPlaceMap extends React.Component {
super(props);
this.state = {
location: [],
address: '',
locationList: [],
locationIndex: -1,
};
......@@ -60,13 +59,13 @@ class SelectPlaceMap extends React.Component {
const info = new qq.maps.InfoWindow({
map: that.map,
position: that.map.center,
content: locationAddress,
content: `<div>地址:${address}<div>`,
zIndex: 99,
visible: true,
});
qq.maps.event.addListener(pointMarker, 'click', () => {
info.open();
info.setContent(locationAddress);
info.setContent(address);
info.setPosition(showLatlng);
});
that.pointArray.push(pointMarker);
......@@ -87,7 +86,7 @@ class SelectPlaceMap extends React.Component {
showLatlng = new qq.maps.LatLng(res.result.location.lat, res.result.location.lng);
let title = '';
if (res.result.address_component.province) {
title = res.result.address_component.province + res.result.address_component.city + res.result.formatted_addresses.rough;
title = res.result.formatted_addresses.rough;
dispatch({
type: 'schooladd/updateState',
payload: {
......@@ -97,6 +96,7 @@ class SelectPlaceMap extends React.Component {
province: res.result.address_component.province,
city: res.result.address_component.city,
district: res.result.address_component.district,
address: title,
},
});
}
......@@ -108,7 +108,7 @@ class SelectPlaceMap extends React.Component {
if (title != '') {
const info = new qq.maps.InfoWindow({
map: that.map,
content: title || '',
content: `<div>地址:${title}<div>`,
position: showLatlng,
zIndex: 99,
visible: true,
......@@ -222,6 +222,7 @@ class SelectPlaceMap extends React.Component {
province: this.state.locationList[index].ad_info.province,
city: this.state.locationList[index].ad_info.city,
district: this.state.locationList[index].ad_info.district,
address: `${this.state.locationList[index].title}`,
},
});
// message.success('已将该地址导入为机构地址,不要忘记保存哦', 2);
......@@ -243,6 +244,7 @@ class SelectPlaceMap extends React.Component {
province: this.state.locationList[index].ad_info.province,
city: this.state.locationList[index].ad_info.city,
district: this.state.locationList[index].ad_info.district,
address: `${this.state.locationList[index].title}`,
},
});
// message.success('已将该地址导入为机构地址,不要忘记保存哦', 2);
......@@ -255,7 +257,9 @@ class SelectPlaceMap extends React.Component {
this.markerArray[index].setZIndex(this.markerArray.length);
}
searchAddress = () => {
const { dispatch, locationAddress, city } = this.props;
const {
dispatch, locationAddress, city, address,
} = this.props;
this.pointArray.forEach((ele) => {
ele.setMap(null);
});
......@@ -321,9 +325,10 @@ class SelectPlaceMap extends React.Component {
province: this.state.locationList[index].ad_info.province,
city: this.state.locationList[index].ad_info.city,
district: this.state.locationList[index].ad_info.district,
address: `${this.state.locationList[index].title}`,
},
});
message.success('已将该地址导入为机构地址,不要忘记保存哦', 2);
// message.success('已将该地址导入为机构地址,不要忘记保存哦', 2);
});
this.listener_arr.push(listener3);
this.map.fitBounds(this.latlngBounds);
......@@ -331,11 +336,12 @@ class SelectPlaceMap extends React.Component {
});
}
searchinput = (e) => {
const { dispatch, locationAddress } = this.props;
const { dispatch, locationAddress, address } = this.props;
dispatch({
type: 'schooladd/updateState',
payload: {
locationAddress: e.target.value,
address: e.target.value,
},
});
}
......@@ -350,10 +356,10 @@ class SelectPlaceMap extends React.Component {
city,
district,
locationAddress,
address,
} = this.props;
const {
location,
address,
locationList,
locationIndex,
} = this.state;
......@@ -391,7 +397,7 @@ class SelectPlaceMap extends React.Component {
className="loginrow"
>
<span className={pageStyles.formitenname}>详细地址:</span>
<Input placeholder="请输入详细地址" className={pageStyles.addressinput} value={locationAddress} onChange={e => this.searchinput(e)} />
<Input placeholder="请输入详细地址" className={pageStyles.addressinput} value={address} onChange={e => this.searchinput(e)} />
<Button type="primary" className={pageStyles.searchbtn} onClick={this.searchAddress}>搜索地图</Button>
</FormItem>
</Col>
......@@ -443,6 +449,7 @@ function mapStateToProps(state) {
province,
city,
district,
address,
} = state.schooladd;
return {
categorys,
......@@ -456,6 +463,7 @@ function mapStateToProps(state) {
province,
city,
district,
address,
};
}
export default connect(mapStateToProps)(SelectPlace);
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