Map View

LocalContextMapView class

google.maps.localContext.LocalContextMapView class

Shows a Local Context experience with aMap.

This class implements LocalContextMapViewOptions.

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

LocalContextMapView
LocalContextMapView(options)
Parameters:
directionsOptions
elementoptional
Type:HTMLElement|SVGElementoptional
This Field is read-only. The DOM Element backing the view.
isTransitioningMapBounds
Type:boolean
Is set totruebeforeLocalContextMapViewbegins changing the bounds of the innerMap,and set tofalseafterLocalContextMapViewfinishes 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 theLocalContextMapViewmay trigger a new search.
locationRestriction
Type:LocationRestrictionoptional
SeeLocalContextMapViewOptions.locationRestriction.Changing this property on theLocalContextMapViewmay trigger a new search.
maxPlaceCount
Type:number
SeeLocalContextMapViewOptions.maxPlaceCount.Changing this property on theLocalContextMapViewmay trigger a new search.
placeTypePreferences
SeeLocalContextMapViewOptions.placeTypePreferences.Changing this property on theLocalContextMapViewmay trigger a new search.Iterable<string|PlaceTypePreference>is also accepted.
Inherited: map, pinOptionsSetup, placeChooserViewSetup, placeDetailsViewSetup
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.
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.

LocalContextMapViewOptions interface

google.maps.localContext.LocalContextMapViewOptions interface

Options for constructing aLocalContextMapView,or accessing an existingLocalContextMapView.

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 instantiatedMapinstance. If passed in, the map will be moved into the LocalContextMapView's DOM, and willnotbe 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.

PlaceTypePreference typedef

google.maps.localContext.PlaceTypePreference typedef

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

{
type:string,
weight:numberoptional
}

MapDirectionsOptions class

google.maps.localContext.MapDirectionsOptions class

Provides settings for directions with aLocalContextMapView.

This class implements MapDirectionsOptionsLiteral.

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

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

MapDirectionsOptionsLiteral interface

google.maps.localContext.MapDirectionsOptionsLiteral interface

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

origin
Origin for directions and distance.

PinOptions interface

google.maps.localContext.PinOptions interface

Options for customizing a pin marker.

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.

PlaceChooserViewSetupOptions interface

google.maps.localContext.PlaceChooserViewSetupOptions interface

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

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

PlaceChooserLayoutMode constants

google.maps.localContext.PlaceChooserLayoutMode constants

Layout modes for the place chooser.

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

HIDDEN Place chooser is hidden.
SHEET Place chooser is shown as a sheet.

PlaceChooserPosition constants

google.maps.localContext.PlaceChooserPosition constants

Display positions for the place chooser.

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

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.)

PlaceDetailsViewSetupOptions interface

google.maps.localContext.PlaceDetailsViewSetupOptions interface

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

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

PlaceDetailsLayoutMode constants

google.maps.localContext.PlaceDetailsLayoutMode constants

Layout modes for the place details.

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

INFO_WINDOW Place details is displayed in anInfoWindow.
SHEET Place details is displayed in a sheet.

PlaceDetailsPosition constants

google.maps.localContext.PlaceDetailsPosition constants

Display positions for the place details.

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

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.)