var url ="http://192.168.1.20:6080/arcgis/rest/services/test/MapServer/export?f=image&format=png&transparent=true";
var tiled = new ol.layer.Image({
    source: new ol.source.ImageWMS({
        ratio: 1, // 缩放比例要设置,设置之后不偏移
        url: url,
        imageLoadFunction: function (image, src) {
            var _src = url;
            var size = map.getSize(),
                bbox = image.extent;
            var params = {
                layers: "show:0",
                layerDefs: '{"0": "name in (\'内蒙古自治区\')"}',
                // layerDefs: '',
                bboxSR: '4326',
                size: size.join(","),
                bbox: bbox.join(",")
            };
            for (var _p in params) {
                _src += "&" + _p + "=" + params[_p]
            }
            image.getImage().src = _src;
        }
    })
});

发表评论