Maps OpenLayers 3 ArcGIS缓存服务器本地文件

Maps OpenLayers 3 ArcGIS缓存服务器本地文件,maps,openlayers,openlayers-3,arcgis,Maps,Openlayers,Openlayers 3,Arcgis,几天前,我使用OpenLayers 2.12制作了一个ArcGiscahevisor,其中一些瓷砖位于该文件夹和文件格式中: \u alllayers\L04\R00000009\c0000a07.png 这意味着我的平铺在“\u alllayers”文件夹中,然后在其他文件夹中,这意味着缩放级别(L00、L01…L21)。在它们里面,我有一些其他的文件夹,它们的名字像:“R00000009”,然后在这些文件夹里,我有一些图像,名字像:“C00000a07.png” 当我为OpenLayers

几天前,我使用OpenLayers 2.12制作了一个ArcGiscahevisor,其中一些瓷砖位于该文件夹和文件格式中:

\u alllayers\L04\R00000009\c0000a07.png

这意味着我的平铺在“\u alllayers”文件夹中,然后在其他文件夹中,这意味着缩放级别(L00、L01…L21)。在它们里面,我有一些其他的文件夹,它们的名字像:“R00000009”,然后在这些文件夹里,我有一些图像,名字像:“C00000a07.png”

当我为OpenLayers 2.12OpenLayers 2.14制作visor时,我做得很好,工作正常。但是当我尝试对OpenLayers 3做同样的操作时,它不起作用

OpenLayers 2.12/OpenLayers 2.14

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <script src="http://maps.google.com/maps/api/js?v=3&amp;sensor=false"></script>
    <meta name="apple-mobile-web-app-capable" content="yes">
    <title>OpenLayers</title>
    <style>
    html, body, #map {
            margin: 0;
            width: 100%;
            height: 100%;
        }

</style>
<script src="lib/OpenLayers.2.14.js"></script>
<script>
    var map, 
        cacheLayer,
        testLayer,
        //This layer requires meta data about the ArcGIS service.  Typically you should use a 
        //JSONP call to get this dynamically.  For this example, we are just going to hard-code
        //an example that we got from here (yes, it's very big):
        //    http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer?f=json&pretty=true
        layerInfo = {
              "currentVersion" : 10.01, 
              "serviceDescription" : "This worldwide street map presents highway-level data for the world and street-level data for the United States, Canada, Japan, Southern Africa, and a number of countries in Europe and elsewhere. This comprehensive street map includes highways, major roads, minor roads, railways, water features, administrative boundaries, cities, parks, and landmarks, overlaid on shaded relief imagery for added context. The street map was developed by ESRI using ESRI basemap data, AND road data, USGS elevation data, and UNEP-WCMC parks and protected areas for the world, and Tele Atlas Dynamap� and Multinet� street data for North America and Europe. Coverage for street-level data in Europe includes Andorra, Austria, Belgium, Czech Republic, Denmark, France, Germany, Great Britain, Greece, Hungary, Ireland, Italy, Luxembourg, Netherlands, Northern Ireland (Belfast only), Norway, Poland, Portugal, San Marino, Slovakia, Spain, Sweden, and Switzerland. Coverage for street-level data elsewhere in the world includes China (Hong Kong only), Colombia, Egypt (Cairo only), Indonesia (Jakarta only), Japan, Mexico (Mexico City only), Russia (Moscow and St. Petersburg only), South Africa, Thailand, and Turkey (Istanbul and Ankara only). For more information on this map, visit us \u003ca href=\"http://goto.arcgisonline.com/maps/World_Street_Map \" target=\"_new\"\u003eonline\u003c/a\u003e.", 
              "mapName" : "Layers", 
              "description" : "This worldwide street map presents highway-level data for the world and street-level data for the United States, Canada, Japan, Southern Africa, most countries in Europe, and several other countries. This comprehensive street map includes highways, major roads, minor roads, one-way arrow indicators, railways, water features, administrative boundaries, cities, parks, and landmarks, overlaid on shaded relief imagery for added context. The map also includes building footprints for selected areas in the United States and Europe and parcel boundaries for much of the lower 48 states.\n\nThe street map was developed by ESRI using ESRI basemap data, DeLorme base map layers, AND road data, USGS elevation data, UNEP-WCMC parks and protected areas for the world, Tele Atlas Dynamap� and Multinet� street data for North America and Europe, and First American parcel data for the United States. Coverage for street-level data in Europe includes Andorra, Austria, Belgium, Czech Republic, Denmark, France, Germany, Great Britain, Greece, Hungary, Ireland, Italy, Luxembourg, Netherlands, Norway, Poland, Portugal, San Marino, Slovakia, Spain, Sweden, and Switzerland. Coverage for street-level data elsewhere in the world includes China (Hong Kong only), Colombia, Egypt (Cairo only), Indonesia (Jakarta only), Japan, Mexico, Russia, South Africa, Thailand, and Turkey (Istanbul and Ankara only). For more information on this map, visit us online at http://goto.arcgisonline.com/maps/World_Street_Map\n", 
              "copyrightText" : "Sources: ESRI, DeLorme, AND, Tele Atlas, First American, ESRI Japan, UNEP-WCMC, USGS, METI, ESRI Hong Kong, ESRI Thailand, Procalculo Prosis", 
              "layers" : [
                {
                  "id" : 0, 
                  "name" : "World Street Map", 
                  "parentLayerId" : -1, 
                  "defaultVisibility" : true, 
                  "subLayerIds" : null, 
                  "minScale" : 0, 
                  "maxScale" : 0
                }
              ], 
              "tables" : [

              ], 
              "spatialReference" : {
                "wkid" : 102100
              }, 
              "singleFusedMapCache" : true, 
              "tileInfo" : {
                "rows" : 256, 
                "cols" : 256, 
                "dpi" : 96, 
                "format" : "JPEG", 
                "compressionQuality" : 90, 
                "origin" : {
                  "x" : -20037700, 
                  "y" : 30241100
                }, 
                "spatialReference" : {
                  "wkid" : 102100
                }, 
                "lods" : [
                    {'level' : 0, 'resolution' : 156543.03403606807, 'scale' : 591657528},
                    {'level' : 1, 'resolution' : 78271.517018034036, 'scale' : 295828764},
                    {'level' : 2, 'resolution' : 39135.758509017018, 'scale' : 147914382},
                    {'level' : 3, 'resolution' : 19567.879254508509, 'scale' : 73957191},
                    {'level' : 4, 'resolution' : 9783.9394949623238, 'scale' : 36978595},
                    {'level' : 5, 'resolution' : 4891.9698797730935, 'scale' : 18489298},
                    {'level' : 6, 'resolution' : 2445.9849398865467, 'scale' : 9244649},
                    {'level' : 7, 'resolution' : 1222.992337651342, 'scale' : 4622324},
                    {'level' : 8, 'resolution' : 611.49616882567102, 'scale' : 2311162},
                    {'level' : 9, 'resolution' : 305.74808441283551, 'scale' : 1155581},
                    {'level' : 10, 'resolution' : 152.87417449834899, 'scale' : 577791},
                    {'level' : 11, 'resolution' : 76.436954957243259, 'scale' : 288895},
                    {'level' : 12, 'resolution' : 38.218609770552874, 'scale' : 144448},
                    {'level' : 13, 'resolution' : 19.109304885276437, 'scale' : 72224},
                    {'level' : 14, 'resolution' : 9.5546524426382184, 'scale' : 36112},
                    {'level' : 15, 'resolution' : 4.7773262213191092, 'scale' : 18056},
                    {'level' : 16, 'resolution' : 2.3886631106595546, 'scale' : 9028},
                    {'level' : 17, 'resolution' : 1.1943315553297773, 'scale' : 4514},
                    {'level' : 18, 'resolution' : 0.59716577766488865, 'scale' : 2257},
                    {'level' : 19, 'resolution' : 0.2984505969011938, 'scale' : 1128},
                    {'level' : 20, 'resolution' : 0.1492252984505969, 'scale' : 564},
                    {'level' : 21, 'resolution' : 0.061383456100245537, 'scale' : 282}
                ]
              }, 
              "initialExtent" : {
                "xmin" : -20037507.0671618, 
                "ymin" : -20037507.0671618, 
                "xmax" : 20037507.0671618, 
                "ymax" : 20037507.0671619, 
                "spatialReference" : {
                  "wkid" : 102100
                }
              }, 
              "fullExtent" : {
                "xmin" : -20037507.0671618, 
                "ymin" : -20037507.0671618, 
                "xmax" : 20037507.0671618, 
                "ymax" : 20037507.0671619, 
                "spatialReference" : {
                  "wkid" : 102100
                }
              }, 
              "units" : "esriMeters", 
              "supportedImageFormatTypes" : "PNG24,PNG,JPG,DIB,TIFF,EMF,PS,PDF,GIF,SVG,SVGZ,AI,BMP", 
              "documentInfo" : {
                "Title" : "World Street Map", 
                "Author" : "ESRI", 
                "Comments" : "", 
                "Subject" : "streets, highways, major roads, railways, water features, administrative boundaries, cities, parks, protected areas, landmarks ", 
                "Category" : "transportation(Transportation Networks) ", 
                "Keywords" : "World, Global, 2009, Japan, UNEP-WCMC", 
                "Credits" : ""
              }, 
              "capabilities" : "Map"
            };
    function init() {
        var maxExtent = new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34);

        var layerMaxExtent = new OpenLayers.Bounds(
            layerInfo.fullExtent.xmin, 
            layerInfo.fullExtent.ymin, 
            layerInfo.fullExtent.xmax, 
            layerInfo.fullExtent.ymax  
        );

        var resolutions = [];
        for (var i=0; i<layerInfo.tileInfo.lods.length; i++) {
            resolutions.push(layerInfo.tileInfo.lods[i].resolution);
        }

        map = new OpenLayers.Map('map', {
            maxExtent: maxExtent,
            StartBounds: layerMaxExtent,
            units: (layerInfo.units == "esriFeet") ? 'ft' : 'm',
            resolutions: resolutions,
            tileSize: new OpenLayers.Size(layerInfo.tileInfo.width, layerInfo.tileInfo.height),                
            projection: 'EPSG:' + layerInfo.spatialReference.wkid
        });

        cacheLayer = new OpenLayers.Layer.ArcGISCache( "AGSCache",
                "http://MY_IP:MY_PORT/MY_FOLDER/Layers/_alllayers", {
                    isBaseLayer: false,
                    useArcGISServer: false,                      
                    resolutions: resolutions,                        
                    tileSize: new OpenLayers.Size(layerInfo.tileInfo.cols, layerInfo.tileInfo.rows),                        
                    tileOrigin: new OpenLayers.LonLat(layerInfo.tileInfo.origin.x , layerInfo.tileInfo.origin.y),                        
                    maxExtent: layerMaxExtent,                        
                    projection: 'EPSG:' + layerInfo.spatialReference.wkid
                });

        testLayer = new OpenLayers.Layer.Google(
            "Google Streets",
            {'sphericalMercator': true, numZoomLevels: 21}
        );

        map.addLayers([cacheLayer, testLayer]);

        map.addControl(new OpenLayers.Control.LayerSwitcher());
        map.addControl( new OpenLayers.Control.MousePosition() );

        map.zoomToExtent(new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34));
    }
    </script>
  </head>
  <body onload="init()">
        <div id="map"></div>
      </body>
    </html>
漂亮的印花

所以,我的问题是:

-为什么OpenLayers 3要求图像(瓷砖)就像它背后的服务一样

-我可以在OpenLayers 3中使用我的瓷砖吗

我已尝试使用以下模式更改URL:

http://MY_IP:MY_PORT/MY_FOLDER/Layers/_alllayers/ImageServer
http://MY_IP:MY_PORT/MY_FOLDER/Layers/_alllayers/ImageServer/export
http://MY_IP:MY_PORT/MY_FOLDER/Layers/_alllayers/Tiles/{z}/{x}/{y}
编辑:

终于我解决了!我用Java编写了一个程序,可以转换所有文件夹和图片的名称

我试图理解文件夹和图像名称的模式,最后我意识到文件夹的第一个字母表示行(R->row),图像的第一个字母表示列(C->column)

删除第一个字母后,只需将该数字从十六进制转换为十进制,并使用新名称保存文件或文件夹


如果有人需要这方面的帮助,我很乐意提供帮助。

ol.source.ArcGISRest
用于ArcGIS服务器互动程序服务。对于ArcGISCache,您需要将
ol.source.TileImage
ol.source.XYZ
与自定义
tileUrlFunction
tileLoadFunction
一起使用。我更喜欢后者,因为这样我就不必转换平铺坐标。差不多

function replacer(match, letter, value) {
  var str = Number(value).toString(letter == 'L' ? 10 : 16);
  var len = letter == 'L' ? 2 : 8;
  while (str.length < len) {
    str = '0' + str;
  }
  return letter + str;
}

var source = new ol.source.XYZ({
  url: 'http://MY_IP:MY_PORT/MY_FOLDER/Layers/_alllayers/L{z}/R{x}/C{y}.png',
  tileLoadFunction: function(image, url) {
    image.getImage().src = url
        .replace(/(L)([0-9]+)/, replacer)
        .replace(/(R)([0-9]+)/, replacer)
        .replace(/(C)([0-9]+)/, replacer);
  }
});
函数替换器(匹配、字母、值){
var str=数字(值).toString(字母=='L'?10:16);
var len=字母=='L'?2:8;
while(str.length
@ahocevar解决方案有效。但是我必须交换URL中的x和y

url: 'http://MY_IP:MY_PORT/MY_FOLDER/Layers/_alllayers/L{z}/R{y}/C{x}.png'
这是有意义的,因为y将映射到行,x映射到列

http://MY_IP:MY_PORT/MY_FOLDER/Layers/_alllayers/ImageServer
http://MY_IP:MY_PORT/MY_FOLDER/Layers/_alllayers/ImageServer/export
http://MY_IP:MY_PORT/MY_FOLDER/Layers/_alllayers/Tiles/{z}/{x}/{y}
function replacer(match, letter, value) {
  var str = Number(value).toString(letter == 'L' ? 10 : 16);
  var len = letter == 'L' ? 2 : 8;
  while (str.length < len) {
    str = '0' + str;
  }
  return letter + str;
}

var source = new ol.source.XYZ({
  url: 'http://MY_IP:MY_PORT/MY_FOLDER/Layers/_alllayers/L{z}/R{x}/C{y}.png',
  tileLoadFunction: function(image, url) {
    image.getImage().src = url
        .replace(/(L)([0-9]+)/, replacer)
        .replace(/(R)([0-9]+)/, replacer)
        .replace(/(C)([0-9]+)/, replacer);
  }
});
url: 'http://MY_IP:MY_PORT/MY_FOLDER/Layers/_alllayers/L{z}/R{y}/C{x}.png'