【发布时间】:2019-06-27 10:25:10
【问题描述】:
如果有人可以帮助我,我会很高兴... 我已经在我的反应项目上安装了 react-leaflet 并且地图组件已成功加载,当我点击地图时我需要获取当前纬度并在弹出窗口中显示它但我不知道如何:(
请……请……帮帮我……
这是我的代码
import React from 'react'
import { Map as LeafletMap, TileLayer, Marker, Popup } from 'react-leaflet';
class Mapp extends React.Component {
componentDidMount() {
}
render() {
return (
<LeafletMap
center={[35.755229,51.304470]}
zoom={16}
maxZoom={20}
attributionControl={true}
zoomControl={true}
doubleClickZoom={true}
scrollWheelZoom={true}
dragging={true}
animate={true}
easeLinearity={0.35}
>
<TileLayer
url='http://{s}.tile.osm.org/{z}/{x}/{y}.png'
/>
<Marker position={[35.755229,51.304470]}
draggable={true}
>
<Popup >
Popup for any custom information.
</Popup>
</Marker>
</LeafletMap>
);
}
}
export default Mapp;
【问题讨论】:
标签: reactjs leaflet react-leaflet