(转)OL记载Arcgis Server切片
http://blog.csdn.net/gisshixisheng/article/details/47955787
概述:
本文讲述如何在OpenLayers中调用Arcgis Server切片并显示。
思路:
在OpenLayers中加载Arcgis Server切片用XYZ图层,Arcgis Server的切片调用地址我们可以看到如下:

可以看到,切片的请求地址为http://localhost:6080/arcgis/rest/services/china/MapServer/z/y/x,其中,z为缩放级别,x,y分别为改切片距离tileOrigin的行列号,其计算方式为:
- var res = this.getResolution();
- var originTileX = (this.tileOrigin.lon + (res * this.tileSize.w/2));
- var originTileY = (this.tileOrigin.lat - (res * this.tileSize.h/2));
- var center = bounds.getCenterLonLat();
- var point = { x: center.lon, y: center.lat };
- var x = (Math.round(Math.abs((center.lon - originTileX) / (res * this.tileSize.w))));
- var y = (Math.round(Math.abs((originTileY - center.lat) / (res * this.tileSize.h))));
- var z = this.map.getZoom();
将之封装为一个OpenLayers扩展类OpenLayers.Layer.AgsTileLayer,该类的代码方式为:
- OpenLayers.Layer.AgsTileLayer = OpenLayers.Class(OpenLayers.Layer.XYZ, {
- url: null,
- tileOrigin: null,
- tileSize: new OpenLayers.Size(256, 256),
- type: 'png',
- useScales: false,
- overrideDPI: false,
- initialize: function(name, url, options) {
- OpenLayers.Layer.XYZ.prototype.initialize.apply(this, arguments);
- },
- getURL: function (bounds) {
- var res = this.getResolution();
- var originTileX = (this.tileOrigin.lon + (res * this.tileSize.w/2));
- var originTileY = (this.tileOrigin.lat - (res * this.tileSize.h/2));
- var center = bounds.getCenterLonLat();
- var point = { x: center.lon, y: center.lat };
- var x = (Math.round(Math.abs((center.lon - originTileX) / (res * this.tileSize.w))));
- var y = (Math.round(Math.abs((originTileY - center.lat) / (res * this.tileSize.h))));
- var z = this.map.getZoom();
- var url = this.url;
- var s = '' + x + y + z;
- if (OpenLayers.Util.isArray(url)) {
- url = this.selectUrl(s, url);
- }
- url = url + '/tile/${z}/${y}/${x}';
- url = OpenLayers.String.format(url, {'x': x, 'y': y, 'z': z});
- return OpenLayers.Util.urlAppend(
- url, OpenLayers.Util.getParameterString(this.params)
- );
- },
- CLASS_NAME: 'OpenLayers.Layer.AgsTileLayer'
- });
调用方式为:
- <script src="AgsTileLayer.js"></script>
- var tiled = new OpenLayers.Layer.AgsTileLayer( "AGSCache",
- "http://localhost:6080/arcgis/rest/services/china/MapServer", {
- isBaseLayer: true,
- tileSize: new OpenLayers.Size(256, 256),
- resolutions: [
- 0.07614275218656896,
- 0.03807137609328448,
- 0.01903568804664224,
- 0.00951784402332112,
- 0.00475892201166056
- ],
- tileOrigin: new OpenLayers.LonLat(-400 , 400),
- maxExtent: bounds,
- projection: 'EPSG:4326'
- });
- map.addLayers([tiled]);
代码中涉及到的参数可以从http://localhost:6080/arcgis/rest/services/china/MapServer?f=pjson返回的JSON数据中获取,如下:
- {
- "capabilities" : "Map,Query,Data",
- "copyrightText" : "",
- "currentVersion" : 10.110,
- "description" : "",
- "documentInfo" : {
- "AntialiasingMode" : "None",
- "Author" : "",
- "Category" : "",
- "Comments" : "",
- "Keywords" : "",
- "Subject" : "",
- "TextAntialiasingMode" : "Force",
- "Title" : ""
- },
- "fullExtent" : {
- "spatialReference" : {
- "latestWkid" : 4326,
- "wkid" : 4326
- },
- "xmax" : 134.9767976465060,
- "xmin" : 73.45100463562233,
- "ymax" : 53.53194315222358,
- "ymin" : 18.16324718764174
- },
- "initialExtent" : {
- "spatialReference" : {
- "latestWkid" : 4326,
- "wkid" : 4326
- },
- "xmax" : 138.0530872970502,
- "xmin" : 70.37471498507816,
- "ymax" : 55.85657468506156,
- "ymin" : 35.30335092712114
- },
- "layers" : [
- {
- "defaultVisibility" : true,
- "id" : 0,
- "maxScale" : 0,
- "minScale" : 0,
- "name" : "province",
- "parentLayerId" : -1,
- "subLayerIds" : null
- },
- {
- "defaultVisibility" : true,
- "id" : 1,
- "maxScale" : 0,
- "minScale" : 0,
- "name" : "bcity",
- "parentLayerId" : -1,
- "subLayerIds" : null
- },
- {
- "defaultVisibility" : true,
- "id" : 2,
- "maxScale" : 0,
- "minScale" : 0,
- "name" : "bcounty",
- "parentLayerId" : -1,
- "subLayerIds" : null
- }
- ],
- "mapName" : "Layers",
- "maxImageHeight" : 2048,
- "maxImageWidth" : 2048,
- "maxRecordCount" : 1000,
- "maxScale" : 1000000,
- "minScale" : 32000000,
- "serviceDescription" : "",
- "singleFusedMapCache" : true,
- "spatialReference" : {
- "latestWkid" : 4326,
- "wkid" : 4326
- },
- "supportedImageFormatTypes" : "PNG32,PNG24,PNG,JPG,DIB,TIFF,EMF,PS,PDF,GIF,SVG,SVGZ,BMP",
- "supportedQueryFormats" : "JSON, AMF",
- "supportsDynamicLayers" : false,
- "tables" : [],
- "tileInfo" : {
- "cols" : 256,
- "compressionQuality" : 0,
- "dpi" : 96,
- "format" : "PNG",
- "lods" : [
- {
- "level" : 0,
- "resolution" : 0.07614275218656896,
- "scale" : 32000000
- },
- {
- "level" : 1,
- "resolution" : 0.03807137609328448,
- "scale" : 16000000
- },
- {
- "level" : 2,
- "resolution" : 0.01903568804664224,
- "scale" : 8000000
- },
- {
- "level" : 3,
- "resolution" : 0.009517844023321120,
- "scale" : 4000000
- },
- {
- "level" : 4,
- "resolution" : 0.004758922011660560,
- "scale" : 2000000
- },
- {
- "level" : 5,
- "resolution" : 0.002379461005830280,
- "scale" : 1000000
- }
- ],
- "origin" : {
- "x" : -400,
- "y" : 400
- },
- "rows" : 256,
- "spatialReference" : {
- "latestWkid" : 4326,
- "wkid" : 4326
- }
- },
- "units" : "esriDecimalDegrees"
- }
(转)OL记载Arcgis Server切片的更多相关文章
- OL记载Arcgis Server切片
概述: 本文讲述怎样在OpenLayers中调用Arcgis Server切片并显示. 思路: 在OpenLayers中载入Arcgis Server切片用XYZ图层,Arcgis Server的切片 ...
- ArcGIS Server开发教程系列(3)切片
切片工作,我们可以一级一级的切,也可以,所有的一块切,Recreate All Tiles这项是说,在没有进行任何的切片工作时,可以选用这项:Recreate Empty Tiles这项是说,如果之前 ...
- ArcGIS Server较早版本切片迁移注意事项
原创文章,转载须标明出处自: http://www.cnblogs.com/gisspace/p/8286838.html -------------------------------------- ...
- arcgis server 无法手动删除切片
背景 问题 场景如下: 切片放置在专门的文件服务器上,通过unc共享路径对外共享.文件服务器的OS为windows server2008R2 想手动更新切片服务的切片.发现同一切片服务,有的比例级别文 ...
- ArcGIS Server 10.4切片图的制作与发布
场景:有一张遥感卫星图,需要以切片图的形式发布 需要的资料:tif的格式遥感图像 发布步骤: 1.选择Service Editor-->Parameters-->Anti-Aliasing ...
- arcgis server地图服务切片(10.4.1)
首先要发布地图服务,过程略 首先,熟悉arcgis server的人应该知道,最直接的切片方式操作方法是在“服务属性”中设置切片,但这种方式可操作性太差,很多设置无法实现,因此不推荐 下面正式开始,打 ...
- Arcgis, ArcEngine, Arcgis Server使用开发汇总 索引
ArcGIS系列软件license及安装: Arcgis SDE10.1 和 Arcgis server10.1的授权文件license tnt_esri.dat Arcgis8.1安装license ...
- ArcGIS API for JavaScript(2)-ArcGIS Server发布要素图层服务
1.前言 上一篇该系列的文章我们主要讲了一下基础Web地图搭建,这篇我们主要讲一下ArcGIS Server发布服务,并且如何调用服务.将自己的数据加载到Web地图当中来,实现Web端浏览数据. 2. ...
- ArcGIS Server开发教程系列(7)使用ArcGIS API for Javascript-Hello World
ArcGIS API for Javascript API下载地址:http://support.esrichina-bj.cn/2011/0223/960.html 选择最新的下载就好了,目前是3 ...
随机推荐
- 【Codeforces 349B】Color the Fence
[链接] 我是链接,点我呀:) [题意] 让你组成一个只由1~9组成的数字 每个数字需要的paint数字给定. 让你组成一个最大的数字,且所有数字的paint的总和不超过v. [题解] 先求出a中的最 ...
- [POJ2104] 区间第k大数 [区间第k大数,可持久化线段树模板题]
可持久化线段树模板题. #include <iostream> #include <algorithm> #include <cstdio> #include &l ...
- 洛谷——P1106 删数问题
https://www.luogu.org/problem/show?pid=1106 题目描述 键盘输入一个高精度的正整数N,去掉其中任意k个数字后剩下的数字按原左右次序将组成一个新的正整数.编程对 ...
- A*算法学习(转)
A*启发式搜索算法详解 人工智能 1导言 1.1 算法 1.2 Dijkstra算法与最佳优先搜索 1.3 A*算法 2 启发式算法 2.1 A*对启发式函数的使用 2.2 速度还是精确度? 2.3 ...
- CF #329 C
C题我还以为是拉格朗日插值... 其实可以想象到,必须有这样一个函数,经过某一点时,其它圆相关的函数要为0. 于是,可以构造这样的一个函数,对于x有 (x/2)*(1-abs(t-i)+abs(1-a ...
- HDU 5434
其实是一道状态DP题.都是行与行之间的转移,可以知道,当某j列中有一个象,如果存在情况i-1行j-1列有象而i,j-1位置无象则不可放,或者i-1,j+1有而i,j+1无同样不可放. 使用快速状态转移 ...
- source 命令的用法,是在当前bash环境下执行脚本文件
原文: http://www.cnblogs.com/softwaretesting/archive/2012/02/13/2349550.html source命令用法: source FileNa ...
- js判断object的具体类型(或者说判断object的类class)
The JavaScript specification gives exactly one proper way to determine the class of an object: Objec ...
- StringIndexOutOfBoundsException
<span style="font-family:Microsoft YaHei;font-size:14px;">public class StringIndexBo ...
- 3D数学读书笔记——多坐标系和向量基础
本系列文章由birdlove1987编写,转载请注明出处. 文章链接: http://blog.csdn.net/zhurui_idea/article/details/24662453 第一个知识点 ...