Javascript 使用WMS和传单弹出窗口
我想知道如何将来自geoserver的地图传单迭代并显示带有信息的弹出窗口。拜托,有人可以在JSFIDLE中做一些事情,这样我就可以理解了,因为我就是不知道怎么做。基本上这就是我想要的,带上一层geoserver,并能够通过每个部分的弹出窗口从中获取信息。我的代码就是它:Javascript 使用WMS和传单弹出窗口,javascript,json,leaflet,geoserver,wms,Javascript,Json,Leaflet,Geoserver,Wms,我想知道如何将来自geoserver的地图传单迭代并显示带有信息的弹出窗口。拜托,有人可以在JSFIDLE中做一些事情,这样我就可以理解了,因为我就是不知道怎么做。基本上这就是我想要的,带上一层geoserver,并能够通过每个部分的弹出窗口从中获取信息。我的代码就是它: var stComerciaisLayer= L.tileLayer.wms("http://...:8080/geoserver/wms/", { layers: 'IGEO:setor_comercia
var stComerciaisLayer= L.tileLayer.wms("http://...:8080/geoserver/wms/", {
layers: 'IGEO:setor_comercial_geo',
format: 'image/png',
transparent: true,
attribution: "Test"
});
我如何放置弹出窗口?谢谢
我完全复制了这个: 但是不起作用:
<script src="L.TileLayer.BetterWMS.js"></script>
var stComerciaisLayer= L.tileLayer.betterWms("http://...:8080/geoserver/wms/", {
layers: 'IGEO:setor_comercial_geo',
format: 'image/png',
transparent: true,
attribution: "Some test"
});
错误提示如下:
Failed to load http://...:8080/geoserver/wms/?REQUEST=GetFeatureInfo&SERVICE=WMS&SRS=EPSG%3A4326&STYLES=&TRANSPARENT=true&VERSION=1.1.1&FORMAT=image%2Fpng&BBOX=-38.74431610107422%2C-4.0605082148574105%2C-38.26400756835938%2C-3.726884196645965&HEIGHT=974&WIDTH=1399&LAYERS=IGEO%3Asetor_comercial_geo&QUERY_LAYERS=IGEO%3Asetor_comercial_geo&INFO_FORMAT=application%2Fjson&X=821&Y=172: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.
leaflet.js:5 Uncaught TypeError: Cannot read property 'lat' of undefined
您显示的错误消息是关于 它表示您的服务器(geoserver)未配置为发送CORS头,因此您的浏览器拒绝从该服务器加载数据,并保持不变 您应该有足够的资源来配置geoserver的CORS头,包括这里的SO或GIS堆栈交换,例如
Failed to load http://...:8080/geoserver/wms/?REQUEST=GetFeatureInfo&SERVICE=WMS&SRS=EPSG%3A4326&STYLES=&TRANSPARENT=true&VERSION=1.1.1&FORMAT=image%2Fpng&BBOX=-38.74431610107422%2C-4.0605082148574105%2C-38.26400756835938%2C-3.726884196645965&HEIGHT=974&WIDTH=1399&LAYERS=IGEO%3Asetor_comercial_geo&QUERY_LAYERS=IGEO%3Asetor_comercial_geo&INFO_FORMAT=application%2Fjson&X=821&Y=172: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.
leaflet.js:5 Uncaught TypeError: Cannot read property 'lat' of undefined