Commit cb9d5a48 authored by baixian's avatar baixian

地图优化1

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