Skip to main content

Hooks System

React HERE Maps is built using a modern hook-based architecture that provides clean, composable functionality.

Core Hooks

useMapContext

Access the map context from any child component:
See Map Context for detailed usage.

useCreateMap

Internal hook used by HereMap to initialize the map instance. Not typically used directly, but understanding it helps with advanced customization.

useMapResize

Automatically handles map resize events. Used internally by HereMap:

Component-Specific Hooks

useMarker

Powers the Marker component. Creates and manages markers:

useMarkerDragBehavior

Handles marker drag functionality:

usePolyline

Creates and manages polylines:

usePolygon

Creates and manages polygons:

Custom Hook Patterns

Creating a Map Bounds Hook

Geolocation Hook

Map Events Hook

Distance Measurement Hook

Hook Best Practices

Build complex functionality by composing simple hooks:
Use useMemo and useCallback for expensive computations:
Always clean up side effects:
Define proper TypeScript types for custom hooks:

See Also

Map Context

Understanding the context system

TypeScript

Type-safe hooks

Examples

Practical hook examples