/** * 市级图层按钮 * @author liuyl 2016-3-8 **/ define([ "base/AppEvent", "dojo", "dojo/_base/declare", "dojo/_base/lang", "controls/toolbar/tools/BaseTool", "dojo/dom-style", "dojo/dom-attr", "utils/LayerUtil" ], function( AppEvent, dojo, declare, lang, BaseTool, domStyle, domAttr, LayerUtil ) { var RL = declare([BaseTool], { layers: { "沈阳市": [{ 'url': 'http://59.46.43.131/Sydlg/wmts', 'type': 'tianditu', "layer": "SYDLG", 'displaylevels': [17, 18, 19], "FORMAT": "image/tile", "TILEMATRIXSET": "Matrix_0" }, { 'url': 'http://59.46.43.131/SydlgLabel/wmts', 'type': 'tianditu', "layer": "SYDLGLabel", 'displaylevels': [17, 18, 19], "FORMAT": "image/tile", "TILEMATRIXSET": "Matrix_0" }], "大连市": [{ 'url': 'http://tianditu.dl.gov.cn/servicemanager/tdtproxy/1061?service=WMTS', 'type': 'tianditu', "layer": "DLMAP", 'displaylevels': [17, 18, 19], "FORMAT": "image/png", "TILEMATRIXSET": "CustomCRS4326ScaleDLMAP" }, { 'url': 'http://tianditu.dl.gov.cn/servicemanager/tdtproxy/1063?service=WMTS', 'type': 'tianditu', "layer": "DLAnnoLayer", 'displaylevels': [17, 18, 19], "FORMAT": "image/png", "TILEMATRIXSET": "CustomCRS4326ScaleDLAnnoLayer" }], "鞍山市": [{ 'url': 'http://services.anshanmap.gov.cn/ASDLG/wmts', 'type': 'tianditu', "layer": "ASDLG", 'displaylevels': [17, 18, 19], "FORMAT": "image/tile", "TILEMATRIXSET": "Matrix_0" }, { 'url': 'http://services.anshanmap.gov.cn/ASDLGLabel/wmts', 'type': 'tianditu', "layer": "ASDLGLabel", 'displaylevels': [17, 18, 19], "FORMAT": "image/tile", "TILEMATRIXSET": "Matrix_0" }], //"抚顺市":[], "本溪市": [{ 'url': 'http://202.97.173.78:8719/newmap/ogc/tianditu/vecmap/wmts', 'type': 'tianditu', "layer": "vecmap", 'displaylevels': [17, 18, 19], "FORMAT": "image/png", "TILEMATRIXSET": "TileMatrixSet_0" }, { 'url': 'http://202.97.173.78:8719/newmap/ogc/tianditu/vecAnno/wmts', 'type': 'tianditu', "layer": "vecAnno", 'displaylevels': [17, 18, 19], "FORMAT": "image/png", "TILEMATRIXSET": "TileMatrixSet_0" }], "丹东市": [{ 'url': 'http://60.21.132.250/WMTS/kvp/services/tdt_vec/MapServer/TDTWMTSServer?SERVICE=WMTS', 'type': 'tianditu', "layer": "tdt_vec", 'displaylevels': [17, 18, 19], "FORMAT": "image/mixed", "TILEMATRIXSET": "tdt_vec" }, { 'url': 'http://60.21.132.250/WMTS/kvp/services/tdt_vec_zj/MapServer/TDTWMTSServer?SERVICE=WMTS', 'type': 'tianditu', "layer": "tdt_vec_zj", 'displaylevels': [17, 18, 19], "FORMAT": "image/mixed", "TILEMATRIXSET": "tdt_vec_zj" }], "锦州市": [{ 'url': 'http://60.21.221.227:8080/WMTS/kvp/services/TDTHXL18_L20/MapServer/TDTWMTSServer?SERVICE=WMTS', 'type': 'tianditu', "layer": "TDTHXL18_L20", 'displaylevels': [17, 18, 19], "FORMAT": "image/mixed", "TILEMATRIXSET": "TDTHXL18_L20" }, { 'url': 'http://60.21.221.227:8080/WMTS/kvp/services/TDTZJL18_L20/MapServer/TDTWMTSServer?SERVICE=WMTS', 'type': 'tianditu', "layer": "TDTZJL18_L20", 'displaylevels': [17, 18, 19], "FORMAT": "image/mixed", "TILEMATRIXSET": "TDTZJL18_L20" }], //"营口市":[], //"辽阳市": [],//节点服务器无法访问 "盘锦市": [{ 'url': 'http://218.61.30.156/WMTS/kvp/services/PJ_dlg/MapServer/TDTWMTSServer?SERVICE=WMTS', 'type': 'tianditu', "layer": "PJ_dlg", 'displaylevels': [17, 18, 19], "FORMAT": "image/mixed", "TILEMATRIXSET": "PJ_dlg" }, { 'url': 'http://218.61.30.156/WMTS/kvp/services/PJ_dlgzj/MapServer/TDTWMTSServer?SERVICE=WMTS', 'type': 'tianditu', "layer": "PJ_dlgzj", 'displaylevels': [17, 18, 19], "FORMAT": "image/mixed", "TILEMATRIXSET": "PJ_dlgzj" }], //矢量注记服务瓦片损坏 // "铁岭市": [{ // 'url': 'http://www.lnditu.gov.cn/WMTS/kvp/services/TlMap_VEC_201512/MapServer/TDTWMTSServer?SERVICE=WMTS', // 'type': 'tianditu', // "layer": "TlMap_VEC_201512", // 'displaylevels': [17,18,19], // "FORMAT":"image/mixed", // "TILEMATRIXSET":"TlMap_VEC_201512" // },{ // 'url': 'http://www.lnditu.gov.cn/WMTS/kvp/services/TlMap_VEC_Anno_201512/MapServer/TDTWMTSServer?SERVICE=WMTS', // 'type': 'tianditu', // "layer": "TlMap_VEC_Anno_201512", // 'displaylevels': [17,18,19], // "FORMAT":"image/mixed", // "TILEMATRIXSET":"TlMap_VEC_Anno_201512" // }], "铁岭市": [{ 'url': 'http://61.161.226.70:6080/arcgis/rest/services/TL_VEC_2015/MapServer', 'type': 'arcgis tiled', 'displaylevels': [17, 18, 19] }], //"朝阳市":[], "葫芦岛市": [{ 'url': 'http://175.150.65.19/WMTS/kvp/services/HLD_SLDT/MapServer/TDTWMTSServer?SERVICE=WMTS', 'type': 'tianditu', "layer": "HLD_SLDT", 'displaylevels': [17, 18, 19], "FORMAT": "image/mixed", "TILEMATRIXSET": "HLD_SLDT" }, { 'url': 'http://175.150.65.19/WMTS/kvp/services/HLD_SLZJ/MapServer/TDTWMTSServer?SERVICE=WMTS', 'type': 'tianditu', "layer": "HLD_SLZJ", 'displaylevels': [17, 18, 19], "FORMAT": "image/mixed", "TILEMATRIXSET": "HLD_SLZJ" }], }, constructor: function(args) { this.tooltip = "市级服务"; this.disableTooltip = "此地区或级别没有市级服务"; this._normalIconClass = "tool-citylayer-normal"; this._overIconClass = "tool-citylayer-over"; this._selectedIconClass = "tool-citylayer-select"; this._disableClass = ""; this.layerObjIndex = {}; this.curCity = ""; AppEvent.addAppEventListener(AppEvent.MAP_DISTRICT_CHANGE, lang.hitch(this, function(evt) { if (this._activated) { if (this.curCity != evt.NAME) { this.hideCityLayers(this.curCity); this.showCityLayers(evt.NAME); } } this.curCity = evt.NAME; })); this.map.on("extent-change", lang.hitch(this, function(evt) { if (evt.levelChange) { if (evt.lod.level >= 17 && this.layers[this.curCity]) { this.enable(); } else { this.deactivate(); this.disable(); } } })); }, disable: function() { this.inherited(arguments); domAttr.set(this.domNode, "title", this.disableTooltip); }, enable: function() { this.inherited(arguments); domAttr.set(this.domNode, "title", this.tooltip); }, showCityLayers: function(name) { var lyrs = this.getCityLayers(name); for (var i = 0; i < lyrs.length; i++) { this.map.addLayer(lyrs[i]); } }, hideCityLayers: function(name) { var lyrs = this.getCityLayers(name); for (var i = 0; i < lyrs.length; i++) { this.map.removeLayer(lyrs[i]); } }, getCityLayers: function(key) { if (this.layerObjIndex[key]) { return this.layerObjIndex[key] } else if (this.layers[key]) { var layerObjs = LayerUtil.parseLayers(this.layers[key]); this.layerObjIndex[key] = layerObjs; return this.layerObjIndex[key] } return []; }, activate: function(args) { if (this._activated) { return; } this.inherited(arguments); if (args != null && args == "self") { return; } this.showCityLayers(this.curCity); }, postCreate: function() { this.inherited(arguments); domStyle.set(this.domNode, "position", "absolute"); domStyle.set(this.domNode, "top", "130px"); domStyle.set(this.domNode, "left", "20px"); domStyle.set(this.domNode, "z-index", "30"); domStyle.set(this.domNode, "border-radius", "3px"); this.disable(); }, deactivate: function() { this.hideCityLayers(this.curCity); this.inherited(arguments); AppEvent.dispatchAppEvent(AppEvent.CLOSE_WIDGET, this.widgetId); } }); return RL; });