javascript - Leaflet - 个性化工具提示
问题描述
我正在尝试个性化传单工具提示以仅显示某些功能。
我的代码如下
var source = L.WMS.source(
"http://13.59.209.218:8080/geoserver/ec2_3/wms?",
options
);
var LandMaps = source.getLayer("ec2_3:PLOTSEDIT", {
onEachFeature: function (feature, layer) {
if (feature.properties) {
var content =
"<table class='table table-striped table-bordered table-condensed'>" +
"<tr><th>ID</th><td>" + feature.properties.id + "</td></tr>" +
"<tr><th>Plot No</th><td>" + feature.properties.plotno_1 + "</td></tr>" +
"<tr><th>FR Source</th><td>" + feature.properties.frsrcname + "</td></tr>" +
"<tr><th>More Details</th><td><a href= 'MoreDetails.html' target='_blank'></a></td></tr>" +
"<table>";
layer.bindPopup(content);
console.log(feature.properties);
}
},
});
LandMaps.addTo(map);
结果仍然是默认工具提示,没有任何格式。如何使用我的代码指定自定义工具提示。我已经为您的测试提供了测试地理服务器。
问候,
詹姆士
解决方案
WMS 没有 onEachFeature 参考。
经过一番搜索,我发现只需在 Geoserver 上使用 WFS 并在 WEBINF 的 web.xml 文件中启用 JSONP。
这是我使用的代码
推荐阅读
- typescript - 通用图形数据结构类的打字稿类型安全
- git - 没有我的密码,如何 git push to master?
- java - 使用java流的字母大小写排列
- google-cloud-platform - 如何对传入流量强制执行 https-only
- c# - WinForms C# xl.Visible 和 xl.UserControl 命令无法正常工作
- amazon-web-services - 在 Cloud Formation 中创建然后更改资源
- python - Python:附加系统路径以导入模块
- python - 使用不同参数时生成重复数据
- asp.net - ASP.NET Core 在视图中将字节数组转换为 svg 图像
- python - 使用没有变量或递归的 lambda 的帕斯卡三角