import React,{useEffect} from 'react'
export default function App() {
useEffect(()=>{
const BMapGL = window.BMapGL;
var map = new BMapGL.Map("container");
map.enableScrollWheelZoom(true); //开启鼠标滚轮缩放
let address='保定'
/ 创建地址解析器实例
var geocoder = new BMapGL.Geocoder();
// 将地址解析结果显示在地图上,并调整地图视野
geocoder.getPoint(address, function (point) {
f (point) {
map.centerAndZoom(point, 16);
map.addOverlay(new BMapGL.Marker(point));
else {
alert("您输入的地址没有解析到结果!");
}
}, "中国");
}
})
return (
<div id='container' style={{width:'100%',height':100%}}>
</div>
)
}
在react中输入地点名称,使用百度地图api找到对应的地点
最新推荐文章于 2024-05-15 17:21:53 发布