Tile3dLayer
Example
Preview
Example Source Code
tsx
import React, { useEffect, useRef, useState } from 'react'
import ReactDOM from 'react-dom'
import { MbMap, MbTiandituLayer } from '@mapbox-react/core'
import { MbTile3dLayer } from '@mapbox-react/deck-layers'
const App = () => {
const [mapCenter] = useState([118.86685053716911, 33.31780722522485])
const [zoom, setZoom] = useState(8)
const [pitch, setPitch] = useState(20)
const mapInst = useRef<any>()
const tileLoadedHandler = (tileset: any) => {
console.log('tileset', tileset)
}
return (
<div className="map-wrapper">
<MbMap ref={mapInst} center={mapCenter} zoom={zoom} pitch={pitch}>
<MbTiandituLayer types={['vec']} />
<MbTile3dLayer data="/json/tileset.json" onLoaded={tileLoadedHandler} />
</MbMap>
</div>
)
}
ReactDOM.render(<App />, document.querySelector('#root'))
API
PROPS
Name | Description | Type | Default |
---|---|---|---|
id | Layer ID | string | - |
autoHighlight | When this property is true and pickable is also true , the hovered object will be highlighted. | boolean | false |
data | Source data for the layer. | string / IndexAny / AnyArr / Promise<any> | '' |
highlightColor | The color to blend with the original color of the highlighted object. | string / number[] | [255, 255, 128, 1] |
highlightedObjectIndex | The index of the currently highlighted element. | number | -1 |
opacity | The opacity of the layer (0-1). | number | 1 |
pickable | Whether the layer responds to mouse events. If false , the component will not emit mouse-related events. | boolean | false |
pointSize | Size of the points. | number | 1 |
show | Whether the layer is visible. | boolean | true |
EVENTS
Name | Description | Parameters |
---|---|---|
onCreated | Initialization complete event | - |
onMouseMove | - | { object: any; coordinates: mapboxgl.LngLat; pixel: [number, number] } |
onMouseLeave | - | - |
clonClickick | - | { object: any; coordinates: mapboxgl.LngLat; pixel: [number, number] } |
onLoaded | - | tileset |
METHODS
Name | Description | Definition |
---|