[英]How to disable popup when is clicked on the leaflet map
This is mu problem, when is clicked on the map it tries to open an pop-up ot something like this and downloads me a file everytime is clicked on the map, how to prevent this...这是 mu 问题,当单击 map 时,它会尝试打开类似这样的弹出窗口,并在每次单击 map 时向我下载一个文件,如何防止这种情况发生……
Code of the layer component:图层组件的代码:
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;
This is how i invoke it in the map:这就是我在 map 中调用它的方式:
<CustomWMSLayer
layers={["Sentinel-2"]}
options={{
format: "image/vnd.jpeg-png",
transparent: "true",
tiled: "true",
crossOrigin: null,
}}
url="https://kade.si/cgi-bin/mapserv?"
/>
I saw this in the console:我在控制台中看到了这个:
But i don't want to make request when is clicked..但我不想在点击时提出请求..
There is a special import in leaflet library called Popup: leaflet 库中有一个名为 Popup 的特殊导入:
Example:例子:
import { Map, TileLayer, Marker, Popup } from "react-leaflet";
You can add it or not.您可以添加或不添加。 If you import it you use it inside of Marker import:
如果您导入它,您将在标记导入中使用它:
<Marker position={position} icon={myIcon}>
<Popup>This is the address</Popup>
</Marker>
identify
will disable the popup, info_format
will define the output format. identify
将禁用弹出窗口, info_format
将定义 output 格式。
Add these to options:将这些添加到选项中:
options={{
format: "image/vnd.jpeg-png",
transparent: "true",
tiled: "true",
crossOrigin: null,
identify: false,
info_format: 'application/json',
}}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.