OpenLayers3 不显示图像
OpenLayers3 Not Displaying Image
我正在使用 openlayers3 编写地图应用程序。我正在从运行良好的 openlayers2 升级。我的问题是从我的 wms 服务器返回的图像没有显示在 div 中。返回的图像是 png 图像。我知道它 returns 是正确的图像,因为我将它保存在我对 WMS 服务器的 api 调用中,并检查了我浏览器中的调试工具,图像显示,返回为 "image/png".我还有一个带有 id="map" 的 div,我设置了 div 的宽度和高度。地图会显示放大和缩小控件,但实际图像不会显示。
代码:
map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Image({
extent: parameters.maxExtent,
source: new ol.source.ImageWMS({
url: '../../WMS/floorplan?',
params: { 'LAYERS': '@Model.LayerName', 'VERSION': '1.3.0', 'FORMAT': "image/png", 'SHAPEFILE': '@Model.ShapeFile'},
ratio: 0.8,
serverType: 'mapserver'
})
})
],
view: new ol.View({
projection: '@Model.Projection',
center: [@Model.CenterLon, @Model.CenterLat],
extent: parameters.maxExtent,
zoom: 0.5
})
});
似乎在 ImageWMS 源上设置小于 1 的比率会导致此问题。请参阅 http://jsfiddle.net/zL9jhgqf/(将比率设置为 1,然后 运行 再次使其起作用)。
source: new ol.source.ImageWMS({
url: 'http://demo.boundlessgeo.com/geoserver/wms',
params: {'LAYERS': 'topp:states'},
ratio: 0.8,
serverType: 'geoserver'
})
我创建了一个关于它的问题,因为我不知道预期的行为是什么:https://github.com/openlayers/ol3/issues/3926
顺便说一句。 WMS 层覆盖小于视口的用例是什么?
我正在使用 openlayers3 编写地图应用程序。我正在从运行良好的 openlayers2 升级。我的问题是从我的 wms 服务器返回的图像没有显示在 div 中。返回的图像是 png 图像。我知道它 returns 是正确的图像,因为我将它保存在我对 WMS 服务器的 api 调用中,并检查了我浏览器中的调试工具,图像显示,返回为 "image/png".我还有一个带有 id="map" 的 div,我设置了 div 的宽度和高度。地图会显示放大和缩小控件,但实际图像不会显示。
代码:
map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Image({
extent: parameters.maxExtent,
source: new ol.source.ImageWMS({
url: '../../WMS/floorplan?',
params: { 'LAYERS': '@Model.LayerName', 'VERSION': '1.3.0', 'FORMAT': "image/png", 'SHAPEFILE': '@Model.ShapeFile'},
ratio: 0.8,
serverType: 'mapserver'
})
})
],
view: new ol.View({
projection: '@Model.Projection',
center: [@Model.CenterLon, @Model.CenterLat],
extent: parameters.maxExtent,
zoom: 0.5
})
});
似乎在 ImageWMS 源上设置小于 1 的比率会导致此问题。请参阅 http://jsfiddle.net/zL9jhgqf/(将比率设置为 1,然后 运行 再次使其起作用)。
source: new ol.source.ImageWMS({
url: 'http://demo.boundlessgeo.com/geoserver/wms',
params: {'LAYERS': 'topp:states'},
ratio: 0.8,
serverType: 'geoserver'
})
我创建了一个关于它的问题,因为我不知道预期的行为是什么:https://github.com/openlayers/ol3/issues/3926
顺便说一句。 WMS 层覆盖小于视口的用例是什么?