From a7715664d2a0bc992b8fa183b91d0f48ada1a386 Mon Sep 17 00:00:00 2001 From: licuizhu <1065490369@qq.com> Date: Sat, 28 Oct 2023 21:08:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=9C=B0=E5=9D=80=E5=92=8C?= =?UTF-8?q?=E7=BB=8F=E7=BA=AC=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/BaseMap/index.js | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/pages/BaseMap/index.js b/src/pages/BaseMap/index.js index a23498aa..bdbee975 100644 --- a/src/pages/BaseMap/index.js +++ b/src/pages/BaseMap/index.js @@ -7,7 +7,7 @@ import Guide from '../../components/Guide/index.ts'; import icon2 from '../../assets/icon/position_icon2.png'; 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'; @@ -86,6 +86,7 @@ class BaseMap extends React.Component{ //根据cityname、adcode、citycode设置地图位置 gotoCity = (data) => { + this.state.map.removeAllMarkers(); let zoom = data.zoom || 10; let lng = data.len || 116.405285; let lat = data.lat || 39.904989; @@ -465,16 +466,14 @@ class BaseMap extends React.Component{ if(this.state.inputExplainKey === 1){ let location = this.state.inputContent let data = { - 'zoom': 13, + 'zoom': 8, 'len': location.split(',')[0], 'lat': location.split(',')[1], } this.gotoCity(data) - let searchPointMarker = new AMap.Marker({ - icon: "https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png", - position: [location.split(',')[0], location.split(',')[1]] - }); - this.state.map.add(searchPointMarker); + let 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]}); + this.state.map.addMarker(searchPointMarker); successSearchAddress(); }else{ let address = this.state.inputContent @@ -493,16 +492,14 @@ class BaseMap extends React.Component{ errorSearchAddress(); }else{ let data = { - 'zoom': 13, + 'zoom': 8, 'len': coordinate.location.split(',')[0], 'lat': coordinate.location.split(',')[1], } this.gotoCity(data) - let searchPointMarker = new AMap.Marker({ - icon: "https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png", - position: [coordinate.location.split(',')[0], coordinate.location.split(',')[1]] - }); - this.state.map.add(searchPointMarker); + let 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]}); + this.state.map.addMarker(searchPointMarker); successSearchAddress(); } }); @@ -529,7 +526,7 @@ class BaseMap extends React.Component{