首页 > 解决方案 > 如何访问/提取我的反应应用程序当前呈现的 GeoJSON?

问题描述

我是 react-leaflet 的新手,我正在尝试访问我的 react 应用程序当前呈现的 GeoJSON(使用 react-leaflet)。更具体地说,我想要下面地图上当前呈现的所有标记的列表。这可能吗?如果可以,怎么做?

在此处输入图像描述

  export const Map = (props) => {

    const classes = useStyles(props)
    const editRef = useRef();

    return (
                    
            <Map
                center={[50.725875,-3.555137]}
                zoom={19}
                maxZoom={19}
                minZoom={8}
                zoomControl={true}
                className={classes.map}
                >

                <TileLayer
                    attribution='&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
                    url="http://{s}.tile.osm.org/{z}/{x}/{y}.png"
                />

                <LayersControl position="topright">
                    <LayersControl.Overlay name="Some Markers...">
                        <LayerGroup>
                            <GeoJSON
                                data={markerData.features}                                
                            >
                            </GeoJSON>
                        </LayerGroup>
                    </LayersControl.Overlay >
                </LayersControl>
            </Map>

  )};

标签: reactjsreact-leaflet

解决方案


推荐阅读