Map
Renders a reactive Google Map
API Reference
Props
| Property | Default | Type/Description |
|---|---|---|
ref | - | (map: google.maps.Map | null) => voidA reference to the map instance. |
id | - | stringAn id for the map, this is required when multiple maps are present in the same APIProvider context. |
style | - | JSX.CSSPropertiesAdditional style rules to apply to the map dom-element. |
class | - | stringAdditional css class-name to apply to the element containing the map. |
colorScheme | - | 'DARK' | 'LIGHT' | 'FOLLOW_SYSTEM'The color-scheme to use for the map. |
renderingType | - | 'VECTOR' | 'RASTER' | 'UNINITIALIZED'The rendering-type to be used.The rendering-type to be used. |
controlled | false | booleanIndicates that the map will be controlled externally. Disables all controls provided by the map itself. |
reuseMaps | false | booleanEnable caching of map-instances created by this component. |
defaultCenter | - | { lat: number; lng: number }The default center point of the map. Required if center and defaultBounds are not provided. |
defaultZoom | - | numberThe default zoom of the map. Required if zoom and defaultBounds are not provided. |
defaultHeading | - | numberThe default heading of the map. Required if heading is not provided. |
defaultTitle | - | numberThe default tilt of the map. Required if tilt is not provided. |
defaultBounds | - | { lat: number; lng: number; padding: number | google.maps.Padding }The default bounds of the map. If this is provided, no defaultCenter or defaultZoom are required. |
backgroundColor | - | stringThe background color of the map div. This color will be visible when tiles have not yet loaded as the user pans |
center | - | { lat: number; lng: number }The center point of the map. |
zoom | - | numberThe zoom of the map. |
heading | - | numberThe heading of the map. |
tilt | - | numberThe tilt of the map. |
clickableIcons | true | booleanIf false, disables clickability of POI icons. |
disableDefaultUI | false | booleanIf true, disables all default UI of the map. |
disableDoubleClickZoom | false | booleanIf true, disables double click zoom on the map. |
draggable | true | booleanIf false, prevents the map from being dragged. |
draggableCursor | - | stringThe name or url of the cursor to display when mousing over a draggable map. |
draggingCursor | - | stringThe name or url of the cursor to display when the map is being dragged. |
fullscreenControl | false | booleanThe enabled state of the Fullscreen control. |
fullscreenControlOptions | - | google.maps.FullscreenControlOptionsThe options for the Fullscreen control. |
gestureHandling | - | 'cooperative' | 'greedy' | none' | 'auto'The gesture handling behavior for the map. |
headingInteractionEnabled | false | booleanWhether the map should allow user control of the camera heading. The option is only in effect when the map is a vector map |
isFractionalZoomEnabled | true for vector maps and false for raster maps | booleanWhether the map should allow fractional zoom levels. |
keyboardShortcuts | true | booleanIf false, prevents the map from being controlled by the keyboard. |
mapId | - | stringThe mapId to use for the map. Required for Cloud Maps and Advanced Markers. DEMO_MAP_ID can be used to try out features that require a map ID |
mapTypeControl | - | booleanThe enabled state of the MapType control. |
mapTypeControlOptions | - | google.maps.MapTypeControlOptionsThe options for the MapType control. |
mapTypeId | 'ROADMAP' | google.maps.MapTypeIdThe initial MapTypeId for the map. |
maxZoom | - | numberThe maximum zoom level of the map. |
minZoom | - | numberThe minimum zoom level of the map. |
noClear | false | booleanIf true, the map will be rendered with no clear. |
panControl | - | booleanThe enabled state of the Pan control. |
panControlOptions | - | google.maps.PanControlOptionsThe options for the Pan control. |
renderingType | 'RASTER' | 'VECTOR' | 'RASTER' | 'UNINITIALIZED'The rendering-type to be used. |
restriction | - | google.maps.MapRestrictionDefines a boundary that restricts the area of the map accessible to users. When set, a user can only pan and zoom while the camera view stays inside the limits of the boundary. |
rotateControl | - | booleanThe enabled state of the Rotate control. |
rotateControlOptions | - | google.maps.RotateControlOptionsThe options for the Rotate control. |
scaleControl | - | booleanThe enabled state of the Scale control. |
scaleControlOptions | - | google.maps.ScaleControlOptionsThe options for the Scale control. |
scrollwheel | true | booleanIf false, disables scrollwheel zooming on the map. |
streetView | - | google.maps.StreetViewPanoramaA StreetView Panorama to display when the Street View pegman is dropped on the map. |
streetViewControl | - | booleanThe enabled state of the StreetView control. |
streetViewControlOptions | - | google.maps.StreetViewControlOptionsThe options for the StreetView control. |
styles | - | google.maps.MapTypeStyle[]Styles to apply to each of the default map types. For satellite, hybrid and terrain modes, these styles will only apply to labels and geometry. Not available when using a mapId or Vector Maps |
tiltInteractionEnabled | false | booleanWhether the map should allow user control of the camera tilt. The option is only in effect when the map is a vector map |
zoomControl | - | booleanThe enabled state of the Zoom control. |
zoomControlOptions | - | google.maps.ZoomControlOptionsThe options for the Zoom control. |
Events
| Event Name | Type/Description |
|---|---|
onBoundsChanged | MapCameraChangedEventFired when the bounds of the map have changed. |
onCenterChanged | MapCameraChangedEventFired when the center of the map has changed. |
onZoomChanged | MapCameraChangedEventFired when the zoom of the map has changed. |
onHeadingChanged | MapCameraChangedEventFired when the heading of the map has changed. |
onTiltChanged | MapCameraChangedEventFired when the tilt of the map has changed. |
onCameraChanged | MapCameraChangedEventFired when the camera of the map has changed. |
onClick | MapMouseEventFired when the map is clicked. |
onDblClick | MapMouseEventFired when the map is double-clicked. |
onContextMenu | MapMouseEventFired when the map is right-clicked. |
onDrag | MapMouseEventFired when the map is dragged. |
onDragEnd | MapMouseEventFired when the map is done being dragged. |
onDragStart | MapMouseEventFired when the map is starting to be dragged. |
onMousemove | MapMouseEventFired when the mouse moves over the map. |
onMouseout | MapMouseEventFired when the mouse moves out of the map. |
onMouseover | MapMouseEventFired when the mouse moves over the map. |
onTilesLoaded | MapEventFired when the visible tiles have finished loading. |
onIdle | MapEventFired when the map becomes idle after panning. |
onProjectionChanged | MapEventFired when the projection has changed. |
onIsFractionalZoomEnabledChanged | MapEventFired when the fractional zoom setting has changed. |
onMapTypeIdChanged | MapEventFired when the map type has changed. |
onRenderingTypeChanged | MapEventFired when the rendering type has changed. |
Event Types
All Map events extend the type MapEvent and have the following properties:
| Property | Type/Description |
|---|---|
type | stringThe type of the event. |
map | google.maps.MapThe map instance that the event was fired on. |
stoppable | booleanIndicates if the event is stoppable. |
stop | () => voidA function that stops the event from propagating further. |
domEvent | MouseEvent | TouchEvent | PointerEvent | KeyboardEvent | EventThe original DOM event that triggered the map event. |
MapMouseEvent
Contains a detail property with the latLng and placeId of the clicked location
{
type: string
map: google.maps.Map
detail: {
latLng: google.maps.LatLngLiteral | null;
placeId: string | null;
}
stoppable: boolean
stop: () => void
domEvent?: MouseEvent | TouchEvent | PointerEvent | KeyboardEvent | Event
}MapCameraChangedEvent
Contains a detail property with the position of the camera
{
type: string
map: google.maps.Map
detail: {
center: google.maps.LatLngLiteral
bounds: google.maps.LatLngBoundsLiteral
zoom: number
heading: number
tilt: number
};
stoppable: boolean
stop: () => void
domEvent?: MouseEvent | TouchEvent | PointerEvent | KeyboardEvent | Event
}