Introducing Places UI Kit: A ready-to-use, low-cost component library that lets you bring the familiar Google Maps UI for Places to any map of your choice. Try it out, andshare your input to help shape the future of GMP!

Map View

LocalContextMapViewclass

google.maps.localContext.LocalContextMapViewclass

Deprecated: Local Context is deprecated, and no longer recommended for new websites. The feature will continue to work, and 12 months notice will be given before support is discontinued. If you are interested in building a Local Context-like experience yourself, we suggest that you check out the "Neighborhood Discovery" solution inQuick Builder or use thePlaces Library, Maps JavaScript API.Code samples andcodelabs for the Places Library can help you.

Notice: Available only in thev=beta channel.

Shows a Local Context experience with aMap.

This class implementsLocalContextMapViewOptions.

Access by callingconst {LocalContextMapView} = await google.maps.importLibrary("localContext"). SeeLibraries in the Maps JavaScript API.

Constructor

LocalContextMapView
LocalContextMapView(options)
Parameters: 

Properties

directionsOptions
elementoptional
Type: HTMLElement|SVGElementoptional
This Field is read-only. The DOM Element backing the view.
isTransitioningMapBounds
Type: boolean
Is set totrue beforeLocalContextMapView begins changing the bounds of the innerMap, and set tofalse afterLocalContextMapView finishes changing the bounds of the innerMap. (Not set when layout mode changes happen due to responsive resizing.)
locationBias
Type: LocationBiasoptional
SeeLocalContextMapViewOptions.locationBias. Changing this property on theLocalContextMapView may trigger a new search.
locationRestriction
Type: LocationRestrictionoptional
SeeLocalContextMapViewOptions.locationRestriction. Changing this property on theLocalContextMapView may trigger a new search.
maxPlaceCount
Type: number
SeeLocalContextMapViewOptions.maxPlaceCount. Changing this property on theLocalContextMapView may trigger a new search.
placeTypePreferences
SeeLocalContextMapViewOptions.placeTypePreferences. Changing this property on theLocalContextMapView may trigger a new search.Iterable<string|PlaceTypePreference> is also accepted.
Inherited:map,pinOptionsSetup,placeChooserViewSetup,placeDetailsViewSetup

Methods

addListener
addListener(eventName, handler)
Parameters: 
Return Value: MapsEventListener
Adds the given listener function to the given event name.
hidePlaceDetailsView
hidePlaceDetailsView()
Parameters:  None
Return Value:  None
Hides the place details.
search
search()
Parameters:  None
Return Value:  None
Searches for places to show the user based on the currentmaxPlaceCount,placeTypePreferences,locationRestriction, andlocationBias.

Events

error
function(event)
Arguments: 
This event is fired if there is an error while performing search.
placedetailsviewhidestart
function()
Arguments:  None
This event is fired before the place details begins animating out.
placedetailsviewshowstart
function()
Arguments:  None
This event is fired before the place details begins animating in.

LocalContextMapViewOptionsinterface

google.maps.localContext.LocalContextMapViewOptionsinterface

Notice: Available only in thev=beta channel.

Options for constructing aLocalContextMapView, or accessing an existingLocalContextMapView.

Properties

maxPlaceCount
Type: number
The maximum number of places to show. When this parameter is 0, the Local Context Library does not load places. [0,24]
placeTypePreferences
The types of places to search for (up to 10). The typeIterable<string|PlaceTypePreference> is also accepted, but is only supported in browsers which natively support JavaScript Symbols.
directionsOptionsoptional
Options for customizing directions. If not set, directions and distance will be disabled.
elementoptional
Type: HTMLElement|SVGElementoptional
This Field is read-only. The DOM Element backing the view.
locationBiasoptional
Type: LocationBiasoptional
Default:null
A soft boundary or hint to use when searching for places.
locationRestrictionoptional
Type: LocationRestrictionoptional
Bounds to constrain search results. If not specified, results will be constrained to the map viewport.
mapoptional
Type: Mapoptional
An already instantiatedMap instance. If passed in, the map will be moved into the LocalContextMapView's DOM, and willnot be re-styled. The element associated with the Map may also have styles and classes applied to it by theLocalContextMapView.
pinOptionsSetupoptional
Type: (function({
  isSelected:boolean,
  isHighlighted:boolean
}): (PinOptionsoptional))|PinOptionsoptional
Configure the place marker icon based on the icon state. Invoked whenever the input to the callback changes. Pass a function to dynamically override the default setup when the LocalContextMapView draws the place marker. Errors and invalid configurations may be determined asynchronously, and will be ignored (defaults will be used, and errors will be logged to the console).
placeChooserViewSetupoptional
Type: (function({
  defaultLayoutMode:PlaceChooserLayoutMode,
  defaultPosition:PlaceChooserPositionoptional
}): (PlaceChooserViewSetupOptionsoptional))|PlaceChooserViewSetupOptionsoptional
Overrides the setup of the place chooser view. Pass a function to dynamically override the default setup when the LocalContextMapView might change its layout due to resizing. Errors and invalid configurations may be determined asynchronously, and will be ignored (defaults will be used instead, and errors will be logged to the console). Errors detected at construction will cause errors to be thrown synchronously.
placeDetailsViewSetupoptional
Type: (function({
  defaultLayoutMode:PlaceDetailsLayoutMode,
  defaultPosition:PlaceDetailsPositionoptional
}): (PlaceDetailsViewSetupOptionsoptional))|PlaceDetailsViewSetupOptionsoptional
Overrides the setup of the place details view. Pass a function to dynamically override the default setup when the LocalContextMapView might change its layout due to resizing. Errors and invalid configurations may be determined asynchronously, and will be ignored (defaults will be used, and errors will be logged to the console). Errors detected at construction will cause errors to be thrown synchronously.

PlaceTypePreferencetypedef

google.maps.localContext.PlaceTypePreferencetypedef

Notice: Available only in thev=beta channel.

A place type to search for, and the weight to use. Ifweight is omitted the library will determine default weights, which may change and improve over time.

{
  type:string,
  weight:numberoptional
}

MapDirectionsOptionsclass

google.maps.localContext.MapDirectionsOptionsclass

Notice: Available only in thev=beta channel.

Provides settings for directions with aLocalContextMapView.

This class implementsMapDirectionsOptionsLiteral.

Access by callingconst {MapDirectionsOptions} = await google.maps.importLibrary("localContext"). SeeLibraries in the Maps JavaScript API.

Properties

Inherited:origin

Methods

addListener
addListener(eventName, handler)
Parameters: 
Return Value: MapsEventListener
Adds the given listener function to the given event name.

MapDirectionsOptionsLiteralinterface

google.maps.localContext.MapDirectionsOptionsLiteralinterface

Notice: Available only in thev=beta channel.

Object literals are accepted in place ofMapDirectionsOptions objects, as a convenience, in many places. These are converted toMapDirectionsOptions objects when the Maps API encounters them.

Properties

origin
Origin for directions and distance.

PinOptionsinterface

google.maps.localContext.PinOptionsinterface

Notice: Available only in thev=beta channel.

Options for customizing a pin marker.

Properties

backgroundoptional
Type: stringoptional
The color of the icon's shape, can be any valid CSS color.
glyphColoroptional
Type: stringoptional
The color of the icon's glyph, can be any valid CSS color.
scaleoptional
Type: numberoptional
The scale of the icon. The value is absolute, not relative to the default sizes in each state.

PlaceChooserViewSetupOptionsinterface

google.maps.localContext.PlaceChooserViewSetupOptionsinterface

Setup options for the place chooser. Read more aboutsetting layout and visibility.

Properties

layoutModeoptional
Type: PlaceChooserLayoutModeoptional
positionoptional
Type: PlaceChooserPositionoptional
Ignored whenlayoutMode:HIDDEN. If not passed, a position will be determined automatically based on thelayoutMode.

PlaceChooserLayoutModeconstants

google.maps.localContext.PlaceChooserLayoutModeconstants

Notice: Available only in thev=beta channel.

Layout modes for the place chooser.

Access by callingconst {PlaceChooserLayoutMode} = await google.maps.importLibrary("localContext"). SeeLibraries in the Maps JavaScript API.

Constants

HIDDENPlace chooser is hidden.
SHEETPlace chooser is shown as a sheet.

PlaceChooserPositionconstants

google.maps.localContext.PlaceChooserPositionconstants

Notice: Available only in thev=beta channel.

Display positions for the place chooser.

Access by callingconst {PlaceChooserPosition} = await google.maps.importLibrary("localContext"). SeeLibraries in the Maps JavaScript API.

Constants

BLOCK_ENDPlace chooser is displayed on a line below the map extending to the end of the container.
INLINE_ENDPlace chooser is displayed inline with the map at the end of the line. (In a left-to-right language this means that the place chooser is to the right of the map.)
INLINE_STARTPlace chooser is displayed inline with the map at the start of the line. (In a left-to-right language this means that the place chooser is to the left of the map.)

PlaceDetailsViewSetupOptionsinterface

google.maps.localContext.PlaceDetailsViewSetupOptionsinterface

Setup options for the place details. Read more aboutsetting layout and visibility.

Properties

hidesOnMapClickoptional
Type: booleanoptional
layoutModeoptional
Type: PlaceDetailsLayoutModeoptional
positionoptional
Type: PlaceDetailsPositionoptional
Ignored whenlayoutMode:INFO_WINDOW. If not passed, a position will be determined automatically based on thelayoutMode.

PlaceDetailsLayoutModeconstants

google.maps.localContext.PlaceDetailsLayoutModeconstants

Notice: Available only in thev=beta channel.

Layout modes for the place details.

Access by callingconst {PlaceDetailsLayoutMode} = await google.maps.importLibrary("localContext"). SeeLibraries in the Maps JavaScript API.

Constants

INFO_WINDOWPlace details is displayed in anInfoWindow.
SHEETPlace details is displayed in a sheet.

PlaceDetailsPositionconstants

google.maps.localContext.PlaceDetailsPositionconstants

Notice: Available only in thev=beta channel.

Display positions for the place details.

Access by callingconst {PlaceDetailsPosition} = await google.maps.importLibrary("localContext"). SeeLibraries in the Maps JavaScript API.

Constants

INLINE_ENDPlace details is displayed inline with the map at the end of the line. (In a left-to-right language this means that the place details is to the right of the map.)
INLINE_STARTPlace details is displayed inline with the map at the start of the line. (In a left-to-right language this means that the place details is to the left of the map.)

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-07-18 UTC.