【发布时间】:2021-03-25 13:17:20
【问题描述】:
我的 react 应用程序使用 react Leaflet 创建了地图:
import {MapContainer TileLayer } from "react-leaflet";
import React from "react";
export default function App() {
return (
<MapContainer
center={[49.1951, 16.6068]}
zoom={13}
scrollWheelZoom={false}
>
<TileLayer
attribution='© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
/>
</MapContainer>
<Search/>
);}
另外,我的 App 有使用 Places 自动完成功能的 Search 组件,我可以从中获取新坐标,这里是:https://github.com/AlonaVa/searchApp/blob/main/search.js
我的任务是将我的地图从搜索组件 (latLng) 重新定位到所选位置。 谢谢你的建议。
【问题讨论】:
标签: javascript reactjs google-api leaflet react-leaflet