Skip to content

WMTSLayer

WMTS Layer, see the WMTS Standard

Example

Example Source Code
tsx
import React, { useEffect, useRef, useState } from 'react'
import ReactDOM from 'react-dom'
import { MbMap, MbWmtsLayer } from '@mapbox-react/core'

const App = () => {
  const [mapCenter] = useState([116.3594627380371, 39.93632920085673])
  const [zoom, setZoom] = useState(10)

  return (
    <div className="map-wrapper">
      <MbMap center={mapCenter} zoom={zoom}>
        <MbWmtsLayer
          url="https://t{s}.tianditu.gov.cn/img_w/wmts?tk=b8ed92ff9b64aebcb0110acca15e478f"
          layerName="img"
          layerStyle="default"
          tileMatrixSetID="w"
          subdomains="01234567"
          maxzoom={18}
        />
      </MbMap>
    </div>
  )
}

ReactDOM.render(<App />, document.querySelector('#root'))

API

PROPS

NameDescriptionTypeDefault
idLayer ID. A unique identifier for the layer.string-
layerNameLayer name. The name of the layer as defined in the WMTS capabilities document.string-
layerStyleLayer style. The style of the layer to be used, as defined in the WMTS capabilities document.string-
tileMatrixSetIDTile Matrix Set ID. Identifies the Tile Matrix Set to be used for this layer, as defined in the WMTS capabilities document. This defines the tiling scheme (resolutions, scales, tile sizes, etc.).string-
tileSizeTile size in pixels. This defines the width and height of each tile. Typically 256 for standard WMTS.number256
urlWMTS server URL. The base URL of the WMTS service endpoint. This URL is used to construct tile requests.string-
formatImage format of the tiles. Common values include image/png, image/jpeg, and image/webp.string'image/png'
maxzoomMaximum zoom level. The highest zoom level at which tiles are available. This corresponds to the highest resolution.number22
minzoomMinimum zoom level. The lowest zoom level at which tiles are available. This corresponds to the lowest resolution.number0
showVisibility of the layer. If true, the layer is displayed; if false, the layer is hidden.booleantrue
subdomainsSubdomains for the URL. This is used for load balancing by distributing tile requests across multiple subdomains. If provided, the URL will be templated with {s} where the subdomain should be inserted (e.g., http://{s}.example.com/wmts). Can be a string or an array of strings.string / string[] / number[]-
tileMatrixPrefixTile Matrix prefix. A prefix that may be added to the TileMatrix identifier in the tile URLs. This is sometimes required by certain WMTS implementations.string-
extraParamsExtra parameters to be added to the tile URLs. These are additional query parameters that can be used to customize tile requests. The value should be a URL query string (e.g., "version=1.0.0&request=GetTile").string-

EVENTS

NameDescriptionParameters
createdInitialization complete event-

METHODS

NameDescriptionDefinition