我正在尝试编写一些OpenLayers javascript,它可以显示位于以下位置的公共REST服务的WMTS流:http://www.mchenrycountygis.org/arcgis/rest/services/2012aerials/MapServer
我遇到的问题是,当我能够看到OpenLayers向端点生成Ajax请求时,它所要求的磁贴不存在。通过使用设置,我可以稍微更改这些URL,但我无法获得正确的设置组合来实际生成有效的URL。
我目前的进展记录在这个jsfiddle中:http://jsfiddle.net/v4WuW/2/
代码也发布在
下面任何帮助将不胜感激!
/**
*我正在尝试使用OpenLayers 1.13.1从这里使用WMTS流: * http://www.mchenrycountygis.org/arcgis/rest/services/2012aerials/MapServer * /
var map = new OpenLayers.Map({ div:“地图”, //问题1:这可能需要EPSG:102671才能匹配WMTS流。为什么 //使用正确的值完全破坏了什么? 投影:“EPSG:900913” });
// matrixIds是通过OpenLayers.Format.WMTSCapabilities()从capabilities.xml中提取的 var matrixIds = [{“supportedCRS”:“urn:ogc:def:crs:EPSG :: 102671”,“identifier”:“0”,“scaleDenominator”:545977.1577380951,“topLeftCorner”:{“lon”: - 17463800, “LAT”:19496100}, “tileWidth”:256, “tileHeight”:256, “matrixWidth”:3 “matrixHeight”:2},{ “supportedCRS”:“瓮:OGC:DEF:CRS:EPSG :: 102671 ”, “标识符”: “1”, “scaleDenominator”:272988.5788690476, “topLeftCorner”:{ “LON”: - 17463800, “LAT”:19496100}, “tileWidth”:256, “tileHeight”:256, “matrixWidth” :4, “matrixHeight”:3},{ “supportedCRS”: “瓮:OGC:DEF:CRS:EPSG :: 102671”, “标识符”: “2”, “scaleDenominator”:136493.81696428568, “topLeftCorner”:{” LON “: - 17463800,” LAT “:19496100},” tileWidth “:256,” tileHeight “:256,” matrixWidth “:6,” matrixHeight “:5},{” supportedCRS “:” 瓮:OGC:DEF: CRS:EPSG :: 102671" , “标识符”: “3”, “scaleDenominator”:68246.43601190475, “topLeftCorner”:{ “LON”: - 17463800, “LAT”:19496100}, “tileWidth”:256, “tileHeight” :256, “matrixWidth”:10 “matrixHeight”:9},{ “supportedCRS”: “瓮:OGC:DEF:CRS:EPSG :: 102671”, “标识符”: “4”, “scaleDenominator”:34122.74553571428, “topLeftCorn ER “:{” LON “: - 17463800,” LAT “:19496100},” tileWidth “:256,” tileHeight “:256,” matrixWidth “:19,” matrixHeight “:18},{” supportedCRS “:” 骨灰盒:OGC:DEF:CRS:EPSG :: 102671" , “标识符”: “5”, “scaleDenominator”:17060.900297619046, “topLeftCorner”:{ “LON”: - 17463800, “LAT”:19496100}, “tileWidth”: 256, “tileHeight”:256, “matrixWidth”:38, “matrixHeight”:35},{ “supportedCRS”: “瓮:OGC:DEF:CRS:EPSG :: 102671”, “标识符”: “6”,” scaleDenominator “:8529.977678571428,” topLeftCorner “:{” LON “: - 17463800,” LAT “:19496100},” tileWidth “:256,” tileHeight “:256,” matrixWidth “:75,” matrixHeight“:68},{ “supportedCRS”: “瓮:OGC:DEF:CRS:EPSG :: 102671”, “标识符”: “7”, “scaleDenominator”:4264.516369047618, “topLeftCorner”:{ “LON”: - 17463800, “LAT”:19496100 }, “tileWidth”:256, “tileHeight”:256, “matrixWidth”:148, “matrixHeight”:135},{ “supportedCRS”: “瓮:OGC:DEF:CRS:EPSG :: 102671”, “标识符” : “8”, “scaleDenominator”:2131.7857142857138, “topLeftCorner”:{ “LON”: - 17463800, “LAT”:19496100}, “tileWidth”:256, “tileHeight”:256, “matrixWidth”:295,“matrixHeight “:271},{” supportedC RS “:” 瓮:OGC:DEF:CRS:EPSG :: 102671" , “标识符”: “9”, “scaleDenominator”:1065.8928571428569, “topLeftCorner”:{ “LON”: - 17463800, “LAT”:19496100} “tileWidth”:256, “tileHeight”:256, “matrixWidth”:589, “matrixHeight”:540},{ “supportedCRS”: “瓮:OGC:DEF:CRS:EPSG :: 102671”, “标识符”: “10”, “scaleDenominator”:566.9642857142857, “topLeftCorner”:{ “LON”: - 17463800, “LAT”:19496100}, “tileWidth”:256, “tileHeight”:256, “matrixWidth”:1107, “matrixHeight” :1013}];
var wmts = new OpenLayers.Layer.WMTS({
url: 'http://www.mchenrycountygis.org/arcgis/rest/services/2012aerials/MapServer/tile/{TileMatrix}/{TileRow}/{TileCol}',
isBaseLayer: true,
requestEncoding: 'REST',
layer: '2012aerials',
matrixSet: "EPSG:102671",
matrixIds : matrixIds,
style: 'default',
/* QUESTION 2
Ajax requests fire for incorrect tile URLs such as: http://www.mchenrycountygis.org/arcgis/rest/services/2012aerials/MapServer/tile/0/27/29
How do I fix this so we are requesting tiles that actually exist, such as: http://www.mchenrycountygis.org/arcgis/rest/services/2012aerials/MapServer/tile/0/135/142
Adding/Removing tileOrigin & tileFullExtent doesn't seem to help...
*/
tileOrigin: new OpenLayers.LonLat(-17463800,19496100),
tileFullExtent: new OpenLayers.Bounds(882499.9493310973, 1990000.0923467577, 1029999.9493310973, 2125000.0923467577),
layers: ''
});
map.addLayers([wmts]);
map.zoomToExtent([807168.3566418022, 2101119.5440438855, 1105331.5420203924, 2131750.0923467577]); // "initial" extent value
//map.zoomToExtent([882499.9493310973, 1990000.0923467577, 1029999.9493310973, 2125000.0923467577]); // "full" extent value
//map.setCenter(new OpenLayers.LonLat(??, ??), 13);