Use this file to discover all available pages before exploring further.
Labels are lightweight visual annotations placed directly on the map surface. Unlike markers, labels are not tied to a places record — they are purely decorative overlays with a title, a description, and an optional icon or color that controls how they appear on the map.Every label must have either an icon or a color (or both). Providing neither will fail schema validation.All operations require authentication via the authedQuery / authedMutation wrappers.
Creates a new label on a map. The map_id and created_by fields are injected automatically — map_id from the mapId argument and created_by from the authenticated user’s context.
The label will fail to insert if both icon and color are null or undefined. Ensure at least one of these fields carries a value.
API path:api.maps.labels.createLabel Type:authedMutation — authentication required
import { useMutation } from "convex/react";import { api } from "@/convex/_generated/api";import { Id } from "@/convex/_generated/dataModel";const createLabel = useMutation(api.maps.labels.createLabel);// Label with an iconawait createLabel({ mapId: "abc123" as Id<"maps">, label: { title: "Historic District", description: "UNESCO-listed area with preserved Edo-period architecture", icon: "Landmark", color: "#f4a261", },});// Label with a color onlyawait createLabel({ mapId: "abc123" as Id<"maps">, label: { title: "No-Go Zone", description: "Construction underway, avoid during trip", color: "#e63946", },});
import { useMutation } from "convex/react";import { api } from "@/convex/_generated/api";import { Id } from "@/convex/_generated/dataModel";const editLabel = useMutation(api.maps.labels.editLabel);await editLabel({ labelId: "label_xyz" as Id<"labels">, label: { title: "Historic District (updated)", description: "Restored in 2024 — now open to visitors again", icon: "Landmark", color: "#2a9d8f", },});
import { useMutation } from "convex/react";import { api } from "@/convex/_generated/api";import { Id } from "@/convex/_generated/dataModel";const deleteLabel = useMutation(api.maps.labels.deleteLabel);await deleteLabel({ labelId: "label_xyz" as Id<"labels"> });