与上一篇提到的方法一样,加载天地图也是通过TiledMapServiceLayer来自定义天地图图层模块。本篇以加载矢量地图为例,讲解如何自定义图层模块以及加载显示图层。
1、加载各类天地图的效果图:
【1】矢量图
【2】影像图
【3】地形图
2、自定义天地图矢量地图图层TiandiLayer:
define(["dojo/_base/declare", "esri/layers/TiledMapServiceLayer", "esri/geometry/Extent", "esri/SpatialReference", "esri/layers/TileInfo"],
function (declare, TiledMapServiceLayer, Extent, SpatialReference, TileInfo) {
return declare( TiledMapServiceLayer, {
// 构造函数
constructor: function () {
// 图层提供的起始显示范围和整个图层的地理范围
// 这里使用坐标系为地理坐标系GCS_WGS_1984(wkid: 4326)
this.spatialReference = new SpatialReference({
wkid: 4326 });
this.initialExtent = (this.fullExtent = new Extent(-180.0, -90.0, 180.0, 90.0, this.spatialReference));
// 图层切片信息
this.tileInfo = new TileInfo({
"rows": 256,
"cols": 256,
"compressionQuality": 0,
"origin": {
"x"