/** * Created by Wandergis on 2015/7/15. */define (["Dojo/_base/declare", "Esri/geometry/extent", "Esri/spatialreference", "Esri/geometry/point", "esri/ Layers/tileinfo "," esri/layers/tiledmapservicelayer "], function (declare, Extent, Spatialreference, point, Tileinfo, T Iledmapservicelayer) {return declare ("Gaodelayer", Tiledmapservicelayer, {layertype: "Road",//layer type Cons Tructor:function (args) {this.spatialreference = new Spatialreference ({wkid:3857 }); Declare.safemixin (this, args); This.fullextent = new Extent (-20037508.342787,-20037508.342787, 20037508.342787, 20037508.342787, This.spatialreference); This.initialextent = this.fullextent; This.tileinfo = new Tileinfo ({"cols": "$", "Rows": $, "compressionquality" : 0, "origin": New Point ( -20037508.342787, 20037508.342787, this.spatialreference), "Spatialreference": This.spatialreference, "LODs": [{"Level": 0, "Resolution": 156543.033928, "scale": 591657527.591555}, {"Level": 1, "Resolution": 78271.5169639999, "scale": 295828763.795777}, { ' Level ': 2, ' resolution ': 39135.7584820001, ' scale ': 147914381.8978 , {"Level": 3, "Resolution": 19567.8792409999, ' Scale ': 73957190.948944}, {"Level": 4, "Resolution": 9783.939620 49996, "scale": 36978595.474472}, {"Level": 5, " Resolution ": 4891.96981024998," scale ": 18489297.737236}, {" Level ": 6, "Resolution ": 2445.98490512499," scale ": 9244648.868618}, {" Level ": 7, "Resolution": 1222.99245256249, "scale": 4622324.434309}, { ' Level ': 8, ' resolution ': 611.49622628138, ' scale ': 2311162.217155 }, {"Level": 9, "Resolution": 305.748113140558, "SCA Le ": 1155581.108577}, {" Level ": Ten," Resolution ": 152.874056570411, ' Scale ': 577790.554289}, {"Level": One, "Resolut Ion ": 76.4370282850732," scale ": 288895.277144}, {" Level ": 12, "Resolution": 38.2185141425366, "scale": 144447.638572}, { "Level": 13, "Resolution": 19.1092570712683, "scale": 72223.819286}, { "Level": +, "Resolution": 9.55462853563415, "scale": 36111.909643 }, {"Level": $, "Resolution": 4.77731426794937, "scale": 1805 5.954822}, {"level": +, "Resolution": 2.38865713397468, ' Scale ': 9027.977411}, {"level": +, "Resolution": 1.19432 856685505, "scale": 4513.988705}, {"Level": 18, "Resolution": 0.597164283559817, "scale": 2256.994353}, {"Level": 1 9, "Resolution": 0.298582141647617, "scale": 1128.497176}] }); This.loaded = true; This.onload (this); },/** * Returns different layers based on different Laytype * @param level * @param row * @param col * @re turns {string} */Gettileurl:function (level, row, col) {var url = ""; Switch (this.layertype) {case "road": url = ' http://webrd0 ' + (col% 4 + 1) + '. Is.auto Navi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=8&x= ' + col + '&y= ' + row + '&z= ' + level; Break Case "st": url = ' http://webst0 ' + (col% 4 + 1) + '. Is.autonavi.com/appmaptile?style=6&x= ' + col + '&y= ' + row + '&z= ' + level; Break Case "label": url = ' http://webst0 ' + (col% 4 + 1) + '. Is.autonavi.com/appmaptile?style=8&x= ' + col + '&y= ' + row + '&z= ' + level; Break Default:url = ' http://webrd0 ' + (col% 4 + 1) + '. IS.AUTONAVI.COM/APPMAPTILE?LANG=ZH_CN&size=1&scale=1&style=8&x= ' + col + '&y= ' + row + '&z= ' + level; Break } return URL; } });});
How to use
1. Configure Dojoconfig before API introduction
<Scripttype= "Text/javascript"> varDojoconfig={async:true, Parseonload:true, Packages: [{name:"extlayers", Location:location.pathname.replace (/\/[^/]*$/, ') + '/extlayers'}]};</script>
2. You can then construct the layer in your code in the following way
Require (["Esri/map", "Extlayers/gaodelayer", "dojo/domready!"], function (map, gaodelayer) { var map = new map ("Map" , { Center: [N/A], zoom:5 }); var baselayer = new Gaodelayer ()///default load vector new Gaodelayer ({layertype: "Road"}) or //var baselayer = new Gaodelayer ({ Layertype: "St"});//Load satellite map //var baselayer = new Gaodelayer ({layertype: "label"});//Load Callout map map.addlayer ( Baselayer);//Add gold maps to map container });
Https://github.com/wandergis/gaodeLayer
Original Blog Link: http://www.thinkgis.cn/topic/55bed4f76edd0d1a1d9f44cf
ArcGIS API for javascript3.x learning Note [5] loading Basemap (iv) "Gold online map"