Skip to content

DelayedPointLayer

Example

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

const App = () => {
  const [mapCenter] = useState([-85.2809895, 42.9340835])
  const [zoom, setZoom] = useState(4)
  const [pitch, setPitch] = useState(0)
  const mapInst = useRef<any>()

  return (
    <div className="map-wrapper">
      <MbMap ref={mapInst} center={mapCenter} zoom={zoom} pitch={pitch}>
        <MbDelayedPointLayer
          data="https://mapbox-web.github.io/mapbox-react/json/americanLibraries.json"
          getPosition={(d) => d.position}
          getFillColor={[49, 92, 114]}
          getRadius={200}
          radiusMinPixels={3}
          getDelayFactor={(d) => {
            const result = Math.abs(d.position[0] + 71) / 50
            return result < 0 ? 0 : result > 1 ? 1 : result
          }}
        />
      </MbMap>
    </div>
  )
}

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

API

PROPS

NameDescriptionTypeDefault
idLayer IDstring-
getDelayFactorFunction to retrieve the delay factor.AnyFunc-
dataSource data for the layer.string / IndexAny / AnyArr / Promise<any>''
showWhether the layer is visible.booleantrue
opacityThe opacity of the layer (0-1).number1
pickableWhether the layer responds to mouse events. If false, the component will not emit mouse-related events.booleanfalse
autoHighlightWhen this property is true and pickable is also true, the hovered object will be highlighted.booleanfalse
highlightColorThe color to blend with the original color of the highlighted object.string / number[][255, 255, 128, 1]
highlightedObjectIndexThe index of the currently highlighted element.number-1
onDataLoadCallback function invoked after data loading is complete.AnyFunc-
dataTransformFunction to transform the data before rendering.AnyFunc-
transitionsTransition settings for the layer.IndexAny{}
radiusUnitsUnits for the radius: 'meters' or 'pixels'.string ('meters', 'pixels')'meters'
radiusScaleA scaling factor applied to the radius.number1
lineWidthUnitsUnits for the line width: 'meter'.string'meter'
lineWidthScaleA scaling factor applied to the line width.number1
strokedWhether the object has a stroke (outline).booleanfalse
filledWhether the object is filled.booleantrue
radiusMinPixelsMinimum radius in pixels.number0
radiusMaxPixelsMaximum radius in pixels.numberNumber.MAX_SAFE_INTEGER
lineWidthMinPixelsMinimum line width in pixels.number0
lineWidthMaxPixelsMaximum line width in pixels.numberNumber.MAX_SAFE_INTEGER
getPositionFunction to retrieve the position. Defaults to accessing the position property of the data object.AnyFunc(d) => d.position
getRadiusFunction to retrieve the radius.number / AnyNumberFunc1
getFillColorFunction to retrieve the fill color.number[] / AnyFunc[0, 0, 0, 255]
getLineColorFunction to retrieve the line color.number[] / AnyFunc[0, 0, 0, 255]
getLineWidthFunction to retrieve the line width.number / AnyNumberFunc1

EVENTS

NameDescriptionParameters

METHODS

NameDescriptionDefinition