前提条件:arcgis server已发布切片服务(使用缓存)
本次使用的是建立好的11级缓存
Arcgis Server服务端信息
Description:
Copyright Text:
Spatial Reference: 4544 (4544)
Single Fused Map Cache: true
Tile Info:
Height: 256
Width: 256
DPI: 96
Levels of Detail: 12
Level ID: 0 [ Start Tile, End Tile ]
Resolution: 132.2919312505292
Scale: 500000
Level ID: 1 [ Start Tile, End Tile ]
Resolution: 66.1459656252646
Scale: 250000
Level ID: 2 [ Start Tile, End Tile ]
Resolution: 33.0729828126323
Scale: 125000
Level ID: 3 [ Start Tile, End Tile ]
Resolution: 16.933367200067735
Scale: 64000
Level ID: 4 [ Start Tile, End Tile ]
Resolution: 8.466683600033868
Scale: 32000
Level ID: 5 [ Start Tile, End Tile ]
Resolution: 4.233341800016934
Scale: 16000
Level ID: 6 [ Start Tile, End Tile ]
Resolution: 2.116670900008467
Scale: 8000
Level ID: 7 [ Start Tile, End Tile ]
Resolution: 1.0583354500042335
Scale: 4000
Level ID: 8 [ Start Tile, End Tile ]
Resolution: 0.5291677250021167
Scale: 2000
Level ID: 9 [ Start Tile, End Tile ]
Resolution: 0.26458386250105836
Scale: 1000
Level ID: 10 [ Start Tile, End Tile ]
Resolution: 0.13229193125052918
Scale: 500
Level ID: 11 [ Start Tile, End Tile ]
Resolution: 0.06614596562526459
Scale: 250
Format: JPEG
Compression Quality: 75.0
Origin: X: -5123200.0
Y: 1.00021E7
Spatial Reference: 4544 (4544)
Initial Extent:
XMin: 394656.66616090515
YMin: 3470399.903611344
XMax: 470539.3179262086
YMax: 3516675.621162779
Spatial Reference: 4544 (4544)
Full Extent:
XMin: 422000
YMin: 3471308.563913471
XMax: 465999.95
YMax: 3514000
Spatial Reference: 4544 (4544)
Units: esriMeters
Supported Image Format Types: PNG32,PNG24,PNG,JPG,DIB,TIFF,EMF,PS,PDF,GIF,SVG,SVGZ,BMP
Document Info:
Title:
Author:
Comments:
Subject:
Category:
Keywords:
AntialiasingMode: None
TextAntialiasingMode: Force
Supports Dynamic Layers: false
MaxRecordCount: 1000
MaxImageHeight: 4096
MaxImageWidth: 4096
Supported Query Formats: JSON, AMF
Min Scale: 500000
Max Scale: 250
openlayers代码
var tileGridWMTS = new ol.tilegrid.WMTS({
//分辨率,每级对应的分辨率,可在arcgis server的mapserver最后面找到
resolutions: [132.2919312505292,
66.1459656252646,
33.0729828126323,
16.933367200067735,
8.466683600033868,
4.233341800016934,
2.116670900008467,
1.0583354500042335,
0.5291677250021167,
0.26458386250105836,
0.13229193125052918,
0.06614596562526459
],
//原点
origin: [-5123200.0, 1.00021E7],
tileSize: 256,
//每级对应的id,与分辨率数组长度一致,必填。可在WMTS描述文档的<ows:Identifier>找到
matrixIds: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11" ]
});
var smOption = {
name: "test",
tileGrid: tileGridWMTS,
matrixSet: 'default028mm',
projection: projection,
layer: "AZImages",
style: "default",
version: "1.0.0",
format: "image/jpg",
transition: 0,
opaque: 0,
requestEncoding: "REST",
//路径可以在WMTS描述文档里面的<ResourceURL>里找到
url: "http://服务器ip:6080/arcgis/rest/services/AZImages/MapServer/WMTS/tile/1.0.0/AZImages/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.jpg"
}
/**
* 底图图层
*/
var baseLayer = new ol.layer.Tile({
source: new ol.source.WMTS(smOption)
});
然后添加到ol.Map的图层里面即可。