Skip to main content
Glama

addMarker

Add a labeled point marker to a 3D globe at specific coordinates. Specify longitude, latitude, label text, color, and size to create visual markers for spatial data visualization.

Instructions

在指定经纬度添加标注点,返回 layerId 供后续操作

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
longitudeYes经度(-180 ~ 180)
latitudeYes纬度(-90 ~ 90)
labelNo标注文本
colorNo标注颜色(CSS 格式)#3B82F6
sizeNo点大小(像素)
idNo自定义图层ID(不传则自动生成)

Implementation Reference

  • The core implementation of the addMarker function which creates a Cesium entity with a point and optional label.
    export function addMarker(viewer: Cesium.Viewer, params: AddMarkerParams): Cesium.Entity {
      const { longitude, latitude, label, color = '#3B82F6', size = 12 } = params
      validateCoordinate(longitude, latitude)
      const cesiumColor = parseColor(color)
    
      return viewer.entities.add({
        position: Cesium.Cartesian3.fromDegrees(longitude, latitude),
        point: {
          pixelSize: size,
          color: cesiumColor,
          outlineColor: Cesium.Color.WHITE,
          outlineWidth: 1,
          heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
          disableDepthTestDistance: Number.POSITIVE_INFINITY,
        },
        label: label
          ? {
              text: label,
              font: '13px sans-serif',
              fillColor: Cesium.Color.WHITE,
              outlineColor: Cesium.Color.BLACK,
              outlineWidth: 2,
              style: Cesium.LabelStyle.FILL_AND_OUTLINE,
              pixelOffset: new Cesium.Cartesian2(0, -18),
              verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
              heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
              disableDepthTestDistance: Number.POSITIVE_INFINITY,
            }
          : undefined,
      })
    }
  • The TypeScript interface defining the parameters required for the addMarker tool.
    export interface AddMarkerParams {
      longitude: number
      latitude: number
      label?: string
      color?: ColorInput
      size?: number
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/gaopengbin/cesium-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server