因此,我试图使用openlayers 5.2加载ArcGOS ImageServer,但是我真的在努力使任何东西正常工作。我编写的代码基于此示例http://openlayers.org/en/latest/examples/vector-esri.html。这是我针对ImageServer而不是FeatureServer的修改版本。我生成的网址是valid,但我不确定如何根据需要将图像添加到源中。
如果有人有任何想法让我知道。
var imageUrl = 'https://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Portland/Aerial/ImageServer';
var xyzGrid = new ol.tilegrid.createXYZ({
tileSize: 512
});
var featureSource = new ol.source.Vector({
loader: function(extent, resolution, projection) {
var url = imageUrl + '/exportImage?bbox=' + extent.join(",") +
'&imageSR=102100' +
'&bboxSR=102100' +
'&pixelType=U8' +
'&f=pjson' +
'&size=512%2C512';
$.ajax({
url: url,
dataType: 'jsonp',
success: function(response) {
console.log(response)
if (response.error) {
console.log(response.error.message + '\n' + response.error.details.join('\n'));
} else {
var source = new ol.source.Image({
url: response.href,
projection: projection,
imageExtent: extent
});
featureSource.addFeatures(source);
}
}});
},
strategy: new ol.loadingstrategy.tile(xyzGrid)
});
var featureService = new ol.layer.Vector({
title: 'ImageServer',
source: featureSource,
});
layers.push(featureService);
答案 0 :(得分:0)
没关系,TileArcGISRest工作正常,但我只需要
params: {
'FORMAT': 'png'
}
因为我的测试服务器不支持默认的“ PNG32”格式。