Map View Stay organized with collections Save and categorize content based on your preferences.
LocalContextMapViewclass
google.maps.localContext.LocalContextMapView
class
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 | Type: MapDirectionsOptions|MapDirectionsOptionsLiteraloptional |
elementoptional | Type: HTMLElement|SVGElementoptional This Field is read-only. The DOM Element backing the view. |
isTransitioningMapBounds | Type: boolean Is set to true 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 See LocalContextMapViewOptions.locationBias . Changing this property on theLocalContextMapView may trigger a new search. |
locationRestriction | Type: LocationRestrictionoptional See LocalContextMapViewOptions.locationRestriction . Changing this property on theLocalContextMapView may trigger a new search. |
maxPlaceCount | Type: number See LocalContextMapViewOptions.maxPlaceCount . Changing this property on theLocalContextMapView may trigger a new search. |
placeTypePreferences | Type: Array<PlaceTypePreference> See LocalContextMapViewOptions.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 current maxPlaceCount ,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.LocalContextMapViewOptions
interface
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 | Type: Array<PlaceTypePreference> The types of places to search for (up to 10). The type Iterable<string|PlaceTypePreference> is also accepted, but is only supported in browsers which natively support JavaScript Symbols. |
directionsOptionsoptional | Type: MapDirectionsOptions|MapDirectionsOptionsLiteraloptional 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 instantiated Map 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({ 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({ 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({ 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.PlaceTypePreference
typedef
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.MapDirectionsOptions
class
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.MapDirectionsOptionsLiteral
interface
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 | Type: LatLng|LatLngLiteral Origin for directions and distance. |
PinOptionsinterface
google.maps.localContext.PinOptions
interface
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.PlaceChooserViewSetupOptions
interface
Setup options for the place chooser. Read more aboutsetting layout and visibility.
Properties | |
---|---|
layoutModeoptional | Type: PlaceChooserLayoutModeoptional |
positionoptional | Type: PlaceChooserPositionoptional Ignored when layoutMode:HIDDEN . If not passed, a position will be determined automatically based on thelayoutMode . |
PlaceChooserLayoutModeconstants
google.maps.localContext.PlaceChooserLayoutMode
constants
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 | |
---|---|
HIDDEN | Place chooser is hidden. |
SHEET | Place chooser is shown as a sheet. |
PlaceChooserPositionconstants
google.maps.localContext.PlaceChooserPosition
constants
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_END | Place chooser is displayed on a line below the map extending to the end of the container. |
INLINE_END | Place 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_START | Place 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.PlaceDetailsViewSetupOptions
interface
Setup options for the place details. Read more aboutsetting layout and visibility.
Properties | |
---|---|
hidesOnMapClickoptional | Type: booleanoptional |
layoutModeoptional | Type: PlaceDetailsLayoutModeoptional |
positionoptional | Type: PlaceDetailsPositionoptional Ignored when layoutMode:INFO_WINDOW . If not passed, a position will be determined automatically based on thelayoutMode . |
PlaceDetailsLayoutModeconstants
google.maps.localContext.PlaceDetailsLayoutMode
constants
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_WINDOW | Place details is displayed in anInfoWindow . |
SHEET | Place details is displayed in a sheet. |
PlaceDetailsPositionconstants
google.maps.localContext.PlaceDetailsPosition
constants
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_END | Place 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_START | Place 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.