l657589096 2015-08-17 08:31 采纳率: 50%
浏览 3216

arcgis api for javascript调用其他地图的问题?

我在网上找到的重写Arcgis的TiledMapServiceLayer调用其他地图的代码。可是我调用TMS服务的时候getTileUrl方法好像不执行(ps:同样的代码调用另一个TMS服务却可以显示地图)。不知道为什么?下面贴出代码和两个TMS服务的返回JSON还有元数据。
代码:
China_tmsLayer.js文件,存放在 web根目录下的/js/tdlib 下面。
define(["dojo/_base/declare", "esri/layers/tiled"], function (declare) {
return declare(esri.layers.TiledMapServiceLayer, {
constructor: function () {
this.spatialReference = new esri.SpatialReference({ wkid: 3857 });
this.initialExtent = (this.fullExtent = new esri.geometry.Extent(8176078.237520736, 379653.95418498217, 15037685.885627579, 7086873.4195843525, this.spatialReference));

        this.tileInfo = new esri.layers.TileInfo({
            "rows": 256,
            "cols": 256,
            "compressionQuality":90,
            "origin": {
                "x": -20037508.34,
                "y": -20037508.34
            },
            "spatialReference": {
                "wkid": 3857
            },
            "lods": [
             { "level": 2, "resolution": 39135.758, "scale": 147914672.0 },
             { "level": 3, "resolution": 19567.879, "scale": 73957336.0 },
             { "level": 4, "resolution": 9783.9395, "scale": 36978668.0 },
             { "level": 5, "resolution": 4891.96975, "scale": 18489334.0 },
             { "level": 6, "resolution": 2445.984875, "scale": 9244667.0 },
             { "level": 7, "resolution": 1222.9924375, "scale": 4622333.5 }
            ]
        });

        this.loaded = true;
        this.onLoad(this);
    },

    getTileUrl: function (level, row, col) {

        return "http://192.168.120.22:8080/gisserver/tmsserver/china_tms/" + level + "/" + row + "/" + col + ".png";

    }
});

});
------------------------------调用上面的China_tmsLayer.js文件。----------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">



China_tms Map
<br> dojoConfig = {<br> parseOnLoad: true,<br> packages: [{<br> name: &#39;tdlib&#39;,<br> location: &quot;/js/tdlib&quot;<br> }]<br> };<br>

<script src="http://js.arcgis.com/3.6/"></script>
<script type="text/javascript">
var map;
require(["esri/map", "tdlib/China_tmsLayer","dojo/domReady!"],
function (Map, China_tmsLayer) {
    map=new Map("mapDiv");
    var basemap = new China_tmsLayer();
    map.addLayer(basemap);
  });
</script>





上面代码不成功,找不到原因
调用不成功的TMS服务的元数据
图片说明
返回的JSON

{"currentVersion":"10.01","mapName":"china_tms","layers":[{"id":"0","name":"tile","defaultVisibility":true,"parentLayerId":"-1","minScale":0.0,"maxScale":0.0}],"spatialReference":{"wkid":3857},"tileInfo":{"rows":256,"cols":256,"dpi":96,"format":"PNG8","compressionQuality":90,"origin":{"x":-2.003750834E7,"y":-2.003750834E7},"spatialReference":{"wkid":3857},"lods":[{"level":2,"resolution":39135.758,"scale":1.47914672E8},{"level":3,"resolution":19567.879,"scale":7.3957336E7},{"level":4,"resolution":9783.9395,"scale":3.6978668E7},{"level":5,"resolution":4891.96975,"scale":1.8489334E7},{"level":6,"resolution":2445.984875,"scale":9244667.0},{"level":7,"resolution":1222.9924375,"scale":4622333.5}]},"initialExtent":{"xmin":8176078.237520736,"ymin":379653.95418498217,"xmax":1.5037685885627579E7,"ymax":7086873.4195843525,"spatialReference":{"wkid":3857}},"fullExtent":{"xmin":8176078.237520736,"ymin":379653.95418498217,"xmax":1.5037685885627579E7,"ymax":7086873.4195843525,"spatialReference":{"wkid":3857}},"units":"esriMeters","capabilities":"Tile"}

可以调用成功的TMS服务的元数据
图片说明
返回的JSON
{"currentVersion":"10.01","serviceDescription":"","mapName":"SZIMAGE","description":"","copyrightText":"","layers":[{"id":"0","name":"SZIMAGE","defaultVisibility":true,"parentLayerId":"-1","minScale":0.0,"maxScale":0.0}],"spatialReference":{"wkid":2327},"singleFusedMapCache":true,"tileInfo":{"rows":256,"cols":256,"dpi":96,"format":"JPEG","compressionQuality":90,"origin":{"x":78488.8,"y":55262.63},"spatialReference":{"wkid":2327},"lods":[{"level":0,"resolution":79.375,"scale":300000.0},{"level":1,"resolution":52.916666666666664,"scale":200000.0},{"level":2,"resolution":26.458333333333332,"scale":100000.0},{"level":3,"resolution":13.229166666666666,"scale":50000.0},{"level":4,"resolution":6.614583333333333,"scale":25000.0},{"level":5,"resolution":3.3072916666666665,"scale":12500.0},{"level":6,"resolution":1.5875,"scale":6000.0},{"level":7,"resolution":0.79375,"scale":3000.0},{"level":8,"resolution":0.5291666666666667,"scale":2000.0},{"level":9,"resolution":0.26458333333333334,"scale":1000.0}]},"initialExtent":{"xmin":78488.8,"ymin":383.034,"xmax":179108.274,"ymax":55262.63,"spatialReference":{"wkid":2327}},"fullExtent":{"xmin":78488.8,"ymin":383.034,"xmax":179108.274,"ymax":55262.63,"spatialReference":{"wkid":2327}},"units":"esriMeters","documentInfo":{"Title":"SZIMAGE","Author":"","Comments":"","Subject":"","Category":"","Keywords":""}}。
学习arcgis api 的新人,好多都不太明白。求大神

  • 写回答

1条回答 默认 最新

  • 你知我知皆知 2024-08-04 05:41
    关注

    以下回答参考 皆我百晓生券券喵儿 等免费微信小程序相关内容作答,并由本人整理回复。

    在使用 ArcGIS API for JavaScript 调用其他地图服务时,可能会遇到一些问题。以下是可能导致问题的原因以及可能的解决方法:

    1. 错误的层ID:确保您使用的层ID与实际使用的层相匹配。
    2. 不同服务的元数据格式:不同的地图服务可能具有不同的元数据格式。例如,一些服务可能没有layers字段,或者包含的元数据类型不同。
    3. URL错误:检查您的TMS服务URL是否正确。URL应包括正确的服务器地址、端口号和路径。
    4. 网络连接问题:请确保您的网络连接正常,并且能够访问指定的服务。
    5. 权限问题:某些服务可能对访问有特定要求或限制。确保您有足够的权限来访问这些服务。
    6. API版本兼容性问题:如果使用的是不同的ArcGIS API版本,请确保您的代码能与当前的ArcGIS API版本兼容。

    如果您尝试了上述所有步骤仍然无法解决问题,建议查看ArcGIS官方文档以获取更详细的帮助信息。同时,如果您能找到更多关于具体服务的详细元数据和API文档,这将有助于进一步定位和解决潜在的问题。

    希望这些建议对您有所帮助!

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#stm32#的问题:寻找一块开发版,作为智能化割草机的控制模块和树莓派主板相连,要求:最低可控制 3 个电机(两个驱动电机,1 个割草电机),其次可以与树莓派主板相连电机照片如下:
  • ¥15 Mac(标签-IDE|关键词-File) idea
  • ¥15 潜在扩散模型的Unet特征提取
  • ¥15 iscsi服务无法访问,如何解决?
  • ¥15 感应式传感器制作的感应式讯响器
  • ¥15 如何使用SC92F8003固件库解析私有协议数据?
  • ¥15 如何在音频中嵌入字符串(水印)信息进行传递
  • ¥30 plc怎么以设计说明书申请软著
  • ¥15 硬盘识别不了,需要初始化,可我的数据怎么办
  • ¥15 lvm2被mask了,怎么unmask都没用(标签-ubuntu|关键词-apt)