查询地址和经纬度

This commit is contained in:
licuizhu 2023-10-28 21:08:52 +08:00
parent bfdf00ce46
commit a7715664d2

View File

@ -7,7 +7,7 @@ import Guide from '../../components/Guide/index.ts';
import icon2 from '../../assets/icon/position_icon2.png'; import icon2 from '../../assets/icon/position_icon2.png';
import Header from '../../components/Header/index.js'; import Header from '../../components/Header/index.js';
import { GaodeMap ,Scene, PointLayer, Heatmap, PolygonLayer } from '@antv/l7'; import { GaodeMap ,Scene, PointLayer, Heatmap, PolygonLayer, Marker, MarkerLayer } from '@antv/l7';
import styles from './index.less'; import styles from './index.less';
@ -86,6 +86,7 @@ class BaseMap extends React.Component{
//根据cityname、adcode、citycode设置地图位置 //根据cityname、adcode、citycode设置地图位置
gotoCity = (data) => { gotoCity = (data) => {
this.state.map.removeAllMarkers();
let zoom = data.zoom || 10; let zoom = data.zoom || 10;
let lng = data.len || 116.405285; let lng = data.len || 116.405285;
let lat = data.lat || 39.904989; let lat = data.lat || 39.904989;
@ -465,16 +466,14 @@ class BaseMap extends React.Component{
if(this.state.inputExplainKey === 1){ if(this.state.inputExplainKey === 1){
let location = this.state.inputContent let location = this.state.inputContent
let data = { let data = {
'zoom': 13, 'zoom': 8,
'len': location.split(',')[0], 'len': location.split(',')[0],
'lat': location.split(',')[1], 'lat': location.split(',')[1],
} }
this.gotoCity(data) this.gotoCity(data)
let searchPointMarker = new AMap.Marker({ let icon = "https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png";
icon: "https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png", let searchPointMarker = new Marker().setLnglat({lng: location.split(',')[0], lat: location.split(',')[1]});
position: [location.split(',')[0], location.split(',')[1]] this.state.map.addMarker(searchPointMarker);
});
this.state.map.add(searchPointMarker);
successSearchAddress(); successSearchAddress();
}else{ }else{
let address = this.state.inputContent let address = this.state.inputContent
@ -493,16 +492,14 @@ class BaseMap extends React.Component{
errorSearchAddress(); errorSearchAddress();
}else{ }else{
let data = { let data = {
'zoom': 13, 'zoom': 8,
'len': coordinate.location.split(',')[0], 'len': coordinate.location.split(',')[0],
'lat': coordinate.location.split(',')[1], 'lat': coordinate.location.split(',')[1],
} }
this.gotoCity(data) this.gotoCity(data)
let searchPointMarker = new AMap.Marker({ let icon = "https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png";
icon: "https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png", let searchPointMarker = new Marker().setLnglat({lng: coordinate.location.split(',')[0], lat: coordinate.location.split(',')[1]});
position: [coordinate.location.split(',')[0], coordinate.location.split(',')[1]] this.state.map.addMarker(searchPointMarker);
});
this.state.map.add(searchPointMarker);
successSearchAddress(); successSearchAddress();
} }
}); });
@ -529,7 +526,7 @@ class BaseMap extends React.Component{
<Col span={12}> <Col span={12}>
<Input.Group compact style={{display:"inline",float:"right"}}> <Input.Group compact style={{display:"inline",float:"right"}}>
<label className={styles.labelForm}>查询</label> <label className={styles.labelForm}>查询</label>
<Select defaultValue="0" onChange={(e)=>{ <Select defaultValue="0" style={{width: '80px'}} onChange={(e)=>{
this.onSearchSwitch(e); this.onSearchSwitch(e);
}}> }}>
<Option value="0">地址</Option> <Option value="0">地址</Option>