0

任何人都可以编写一些代码来从用户那里获取输入(坐标)以在地图上显示为标记,并继续添加带有新纬度、经度的标记以及删除标记的选项。请。

我已经写了这段代码: 在此处输入图像描述

4

1 回答 1

0

这段代码应该可以工作,如果没有,请告诉我。

const [position,setPosition] = useState([]);

const getLocation = () => {
        navigator.geolocation.getCurrentPosition(function(pos) {
            setPosition([pos.coords.latitude,pos.coords.longitude]);
        },);
于 2022-02-14T18:30:09.500 回答