这是亩问题,当在地图上单击时,它试图打开一个类似这样的弹出窗口,每次在地图上单击时,都向我下载文件,如何防止这种情况...
图层组件的代码:
import { 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;
}
export default CustomWMSLayer;
这就是我在地图中调用它的方式:
<CustomWMSLayer
layers={["Sentinel-2"]}
options={{
format: "image/vnd.jpeg-png",
transparent: "true",
tiled: "true",
crossOrigin: null,
}}
url="https://kade.si/cgi-bin/mapserv?"
/>
但是我不想在单击时发出请求。
答案 0 :(得分:0)
在传单库中有一个特殊的导入称为Popup:
示例:
import { Map, TileLayer, Marker, Popup } from "react-leaflet";
您可以添加或不添加。如果您导入它,则可以在标记导入中使用它:
<Marker position={position} icon={myIcon}>
<Popup>This is the address</Popup>
</Marker>
答案 1 :(得分:0)
identify
将禁用弹出窗口,info_format
将定义输出格式。
将这些添加到选项:
options={{
format: "image/vnd.jpeg-png",
transparent: "true",
tiled: "true",
crossOrigin: null,
identify: false,
info_format: 'application/json',
}}