11/* Copyright© 2000 - 2020 SuperMap Software Co.Ltd. All rights reserved.
22 * This program are made available under the terms of the Apache License, Version 2.0
33 * which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
4- import L from "leaflet" ;
5- import "../core/Base" ;
6- import {
7- WMTSLayer
8- } from "./TileLayer.WMTS" ;
9- import Attributions from '../core/Attributions'
4+ import L from 'leaflet' ;
5+ import '../core/Base' ;
6+ import { WMTSLayer } from './TileLayer.WMTS' ;
7+ import Attributions from '../core/Attributions' ;
108
119/**
1210 * @class L.supermap.tiandituTileLayer
@@ -22,30 +20,35 @@ import Attributions from '../core/Attributions'
2220 * @param {boolean } [options.isLabel=false] - 是否是标注图层。
2321 * @param {Array.<number> } [options.subdomains=[0, 1, 2, 3, 4, 5, 6, 7]] - 子域名数组。
2422 * @param {string } [options.attribution='Map Data <a href='https://www.tianditu.gov.cn' target='_blank'><img style='background-color:transparent;bottom:2px;opacity:1;' src='https://api.tianditu.gov.cn/img/map/logo.png' width='53px' height='22px' opacity='0'></a>'] - 版权信息
23+ * @param {string } [options.noWrap=true] - 图层是否X方向平铺。
2524 */
2625export var TiandituTileLayer = WMTSLayer . extend ( {
27-
2826 layerLabelMap : {
29- " vec" : " cva" ,
30- " ter" : " cta" ,
31- " img" : " cia"
27+ vec : ' cva' ,
28+ ter : ' cta' ,
29+ img : ' cia'
3230 } ,
3331 layerZoomMap : {
34- " vec" : 18 ,
35- " ter" : 14 ,
36- " img" : 18
32+ vec : 18 ,
33+ ter : 14 ,
34+ img : 18
3735 } ,
3836 options : {
39- layerType : " vec" , //(vec:矢量图层,vec:矢量标签图层,img:影像图层,cia:影像标签图层,ter:地形,cta:地形标签图层)
37+ layerType : ' vec' , //(vec:矢量图层,vec:矢量标签图层,img:影像图层,cia:影像标签图层,ter:地形,cta:地形标签图层)
4038 isLabel : false ,
4139 attribution : Attributions . Tianditu . attribution ,
42- url : " https://t{s}.tianditu.gov.cn/{layer}_{proj}/wmts?" ,
40+ url : ' https://t{s}.tianditu.gov.cn/{layer}_{proj}/wmts?' ,
4341 zoomOffset : 1 ,
44- key : "" ,
42+ key : '' ,
4543 dpi : 96 ,
46- style : "default" ,
47- format : "tiles" ,
48- subdomains : [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ]
44+ style : 'default' ,
45+ format : 'tiles' ,
46+ subdomains : [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ] ,
47+ bounds : [
48+ [ - 90 , - 180 ] ,
49+ [ 90 , 180 ]
50+ ] ,
51+ noWrap : true
4952 } ,
5053
5154 initialize : function ( options ) {
@@ -63,10 +66,27 @@ export var TiandituTileLayer = WMTSLayer.extend({
6366 this . options . tilematrixSet = map . options . crs . code === "EPSG:4326" ? "c" : "w" ;
6467 this . _url = this . _url . replace ( "{layer}" , this . options . layer ) . replace ( "{proj}" , this . options . tilematrixSet ) ;
6568 WMTSLayer . prototype . onAdd . call ( this , map ) ;
69+ } ,
70+ _isValidTile : function ( coords ) {
71+ const crs = this . _map . options . crs ;
72+ if ( ! crs . infinite ) {
73+ const bounds = this . _globalTileRange ;
74+ if (
75+ ( ( ! crs . wrapLng || this . options . noWrap ) && ( coords . x < bounds . min . x || coords . x > bounds . max . x ) ) ||
76+ ( ! crs . wrapLat && ( coords . y < bounds . min . y || coords . y > bounds . max . y ) )
77+ ) {
78+ return false ;
79+ }
80+ }
81+ if ( ! this . options . bounds ) {
82+ return true ;
83+ }
84+ const tileBounds = this . _tileCoordsToBounds ( coords ) ;
85+ return L . latLngBounds ( this . options . bounds ) . overlaps ( tileBounds ) ;
6686 }
6787} ) ;
6888export var tiandituTileLayer = function ( options ) {
6989 return new TiandituTileLayer ( options ) ;
7090} ;
7191
72- L . supermap . tiandituTileLayer = tiandituTileLayer ;
92+ L . supermap . tiandituTileLayer = tiandituTileLayer ;
0 commit comments