Reactjs 如何从react传单调用getFeatureInfo?

Reactjs 如何从react传单调用getFeatureInfo?,reactjs,leaflet,maps,openstreetmap,react-leaflet,Reactjs,Leaflet,Maps,Openstreetmap,React Leaflet,我从github获得了如何添加wms层的示例: 但是如何从wms层单击获取FeatureInfo?react传单WMSTileLayer组件实现核心传单L.TileLayer哪个getFeatureInfo: 没有GetCapabilities支持,没有legend支持,也没有 GetFeatureInfo支持 可以考虑使用WMS插件来支持 GETFrimeRealsFix,例如 安装步骤: 安装传单.wms软件包: npm i leaflet.wms 为WMS层引入一个组件: import

我从github获得了如何添加wms层的示例:


但是如何从wms层单击获取FeatureInfo?

react传单
WMSTileLayer
组件实现核心传单
L.TileLayer
哪个
getFeatureInfo

没有GetCapabilities支持,没有legend支持,也没有 GetFeatureInfo支持

可以考虑使用WMS插件来支持<代码> GETFrimeRealsFix<代码>,例如

安装步骤:

安装
传单.wms
软件包:

npm i leaflet.wms
为WMS层引入一个组件:

import React, { Component } from 'react';
import { withLeaflet, useLeaflet } from "react-leaflet";
import * as WMS from "leaflet.wms";

function CustomWMSLayer(props) {
    const { url, options,layers } = props;
    const ctx = useLeaflet()
    const map = ctx.map;


    // Add WMS source/layers
    const source = WMS.source(
        url,
        options
    );

    for(let name of layers){
        source.getLayer(name).addTo(map)
    }

    return null;
}
结果


在React传单V3中,使用传单和with传单挂钩替换为useMap。@Vadim Gremyachev代码的更新如下所示

import React from 'react';
import {  useMap } from "react-leaflet";
import * as WMS from "leaflet.wms";

function GetFeatureInfoWms(props) {
    const { url, options,layers } = props;
    const map = useMap()

// Add WMS source/layers
const source = WMS.source(
    url,
    options
);

for(let name of layers){
    source.getLayer(name).addTo(map)
}
return null;
}