Skip to content

ColumnLayer

Example

Example Source Code
vue
<template>
  <div style="height: 500px">
    <div style="height: 470px">
      <mb-map :pitch="60" :bearing="30" :zoom="10">
        <mb-tianditu-layer />
        <mb-column-layer
          :data="__RESOURCE_URL__ + 'json/beijing_price.json'"
          :position="(d) => d.lnglat"
          :elevation="(d) => d.transPrice / 30"
          :fill-color="
            (d) => `rgba(${(d.transPrice / 10000) * 15},125,125,0.8)`
          "
          :radius="150"
          :pickable="true"
          :auto-highlight="true"
          @mousemove="mousemoveHandler"
          @mouseleave="mouseleaveHandler"
        />
      </mb-map>
    </div>
    <div style="height: 30px; margin: 10px 10px">
      <p v-if="comunity" class="text-muted">
        {{
          comunity.name
            ? `${comunity.name} ${comunity.transPrice / 10000}thousand/m2`
            : ''
        }}
      </p>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'

const comunity = ref<Record<string, any>>({})

const mousemoveHandler = ({ object }: { object: any }) => {
  if (object) {
    comunity.value = object
  }
}
const mouseleaveHandler = () => {
  comunity.value = {}
}
</script>

API

PROPS

NameDescriptionTypeDefault
idLayer ID. A unique identifier for the layer.string-
radiusRadius of the shape in meters.number1000
positionFunction to retrieve the position of each data point. This function should accept a data item as an argument and return an array representing the [longitude, latitude] or [longitude, latitude, altitude/elevation].function-
auto-highlightWhen this property is true and pickable is also true, the object under the mouse cursor will be highlighted. This provides visual feedback when hovering over interactive elements.booleanfalse
dataSource data for the layer. This can be a string representing a URL, an object, an array, or a Promise that resolves to data.string / IndexAny / AnyArr / Promise<any>''
elevationElevation/Height of the shape. This can be a fixed number or a function that returns the elevation based on the data.number / AnyNumberFunc1000
extrudedWhether the shapes are rendered in 3D (extruded).booleantrue
fill-colorFill color of the shape. This can be a string representing a color name (e.g., 'red', 'blue'), a function that returns a color based on the data, or an array of RGBA values (e.g., [255, 0, 0, 255] for red).string / AnyFunc'black'
filledWhether the shapes are filled.booleantrue
highlight-colorThe color to blend with the original color of the highlighted object. This creates the highlight effect. The value can be a color string or an RGBA array.string / number[][255, 255, 128, 1]
highlighted-object-indexThe index of the currently highlighted object within the data. A value of -1 indicates that no object is currently highlighted.number-1
line-colorLine color of the shape's outline. This can be a string representing a color name, a function that returns a color based on the data, or an array of RGBA values.string / AnyFunc'black'
line-widthWidth of the shape's outline. This can be a fixed number or a function that returns the line width based on the data.string / AnyNumberFunc1
line-width-max-pixelsThe maximum line width in pixels. This limits the maximum width of the rendered lines.numberNumber.MAX_SAFE_INTEGER
line-width-min-pixelsThe minimum line width in pixels. This ensures that lines are not rendered with a width smaller than this value.number0
line-width-scaleA scaling factor applied to the line width. This allows you to easily adjust the width of all lines in the layer.number1
line-width-unitsUnits for the line width: 'pixels' or 'meters'. Specifies whether the width values are interpreted as pixels on screen or meters in world space. This is especially relevant for geographic visualizations where the width should represent a physical distance.string ('pixels', 'meters')'meters'
opacityThe opacity of the shape (0-1). 0 is fully transparent, and 1 is fully opaque.number1
pickableWhether the layer responds to mouse events. If false, the component will not emit mouse-related events (e.g., click, hover).booleanfalse
showWhether the layer is visible. If true, the layer will be rendered; otherwise, it will be hidden.booleantrue
strokedWhether the shapes have an outline (stroke).booleanfalse

EVENTS

NameDescriptionParameters
createdInitialization complete event-
mousemove-{ object: any; coordinates: mapboxgl.LngLat; pixel: [number, number] }
mouseleave--
click-{ object: any; coordinates: mapboxgl.LngLat; pixel: [number, number] }

SLOTS

NameDescription

METHODS

NameDescriptionDefinition