Data-driven styling Stay organized with collections Save and categorize content based on your preferences.
FeatureLayerinterface
google.maps.FeatureLayerinterface
An interface representing a map layer containing features of a specificFeatureType whose style can be overridden client-side, or have events attached.
Properties | |
|---|---|
featureType | Type: FeatureTypeThe FeatureType associated with thisFeatureLayer. |
isAvailable | Type: booleanWhether this FeatureLayer is available, meaning whether Data-driven styling is available for this map (there is a map ID using vector tiles with thisFeatureLayer enabled in the Google Cloud Console map style.) If this is false (or becomes false), styling on thisFeatureLayer returns to default and events are not triggered. |
| Notice: Available only in thev=beta channel. Type: stringoptionalThe Dataset ID for this FeatureLayer. Only present if thefeatureType isFeatureType.DATASET. |
styleoptional | Type: FeatureStyleOptions|FeatureStyleFunctionoptionalThe style of Features in theFeatureLayer. The style is applied when style is set. If your style function updates, you must set the style property again. AFeatureStyleFunction must return consistent results when it is applied over the map tiles, and should be optimized for performance. Asynchronous functions are not supported. If you use aFeatureStyleOptions, all features of that layer will be styled with the sameFeatureStyleOptions. Set the style tonull to remove the previously set style. If thisFeatureLayer is not available, setting style does nothing and logs an error. |
Methods | |
|---|---|
addListener | addListener(eventName, handler)Parameters:
Return Value: MapsEventListener Resulting event listener.Adds the given listener function to the given event name. Returns an identifier for this listener that can be used with event.removeListener. |
Events | |
|---|---|
click | function(event)Arguments:
This event is fired when the FeatureLayer is clicked. |
mousemove | function(event)Arguments:
This event is fired when the user's mouse moves over the FeatureLayer. |
FeatureTypeconstants
google.maps.FeatureTypeconstants
Identifiers for feature types.
Access by callingconst {FeatureType} = await google.maps.importLibrary("maps").
SeeLibraries in the Maps JavaScript API.
Constants | |
|---|---|
ADMINISTRATIVE_AREA_LEVEL_1 | Indicates a first-order civil entity below the country level. |
ADMINISTRATIVE_AREA_LEVEL_2 | Indicates a second-order civil entity below the country level. |
COUNTRY | Indicates the national political entity. |
| Notice: Available only in thev=beta channel. Indicates a third-party dataset. |
LOCALITY | Indicates an incorporated city or town political entity. |
POSTAL_CODE | Indicates a postal code as used to address postal mail within the country. Includes zip codes. |
SCHOOL_DISTRICT | Indicates a school district. |
FeatureStyleFunctiontypedef
google.maps.FeatureStyleFunctiontypedef
A function to style aFeatureLayer.
function(FeatureStyleFunctionOptions): (FeatureStyleOptionsoptional)
FeatureStyleFunctionOptionsinterface
google.maps.FeatureStyleFunctionOptionsinterface
Options passed to aFeatureStyleFunction.
Properties | |
|---|---|
feature | Type: FeatureFeature passed into theFeatureStyleFunction for styling. |
FeatureStyleOptionsinterface
google.maps.FeatureStyleOptionsinterface
These options specify the way the style of aFeature should be modified on a map.
Properties | |
|---|---|
fillColoroptional | Type: stringoptionalHex RGB string (like "#00FF00" for green). Only applies to polygon geometries. |
fillOpacityoptional | Type: numberoptionalThe fill opacity between 0.0 and 1.0. Only applies to polygon geometries. |
strokeColoroptional | Type: stringoptionalHex RGB string (like "#00FF00" for green). |
strokeOpacityoptional | Type: numberoptionalThe stroke opacity between 0.0 and 1.0. Only applies to line and polygon geometries. |
strokeWeightoptional | Type: numberoptionalThe stroke width in pixels. Only applies to line and polygon geometries. |
Featureinterface
google.maps.Featureinterface
An interface representing a vector map tile feature. These are inputs to theFeatureStyleFunction. Do not save a reference to a particularFeature object because the reference will not be stable.
Properties | |
|---|---|
featureType | Type: FeatureTypeFeatureType of thisFeature. |
PlaceFeatureinterface
google.maps.PlaceFeatureinterface
An interface representing a feature with a place ID which includes features of typeFeatureType.ADMINISTRATIVE_AREA_LEVEL_1,FeatureType.ADMINISTRATIVE_AREA_LEVEL_2,FeatureType.COUNTRY,FeatureType.LOCALITY,FeatureType.POSTAL_CODE, andFeatureType.SCHOOL_DISTRICT.
This interface extendsFeature.
Properties | |
|---|---|
placeId | Type: string |
Inherited:featureType | |
Methods | |
|---|---|
fetchPlace | fetchPlace()Parameters: None Fetches a Place for thisPlaceFeature. In the resultingPlace object, theid and thedisplayName properties will be populated. The display name will be in the language the end user sees on the map. (Additional fields can be subsequently requested viaPlace.fetchFields() subject to normal Places API enablement and billing.) Do not call this from aFeatureStyleFunction since only synchronous FeatureStyleFunctions are supported. The promise is rejected if there was an error fetching thePlace. |
DatasetFeatureinterface
google.maps.DatasetFeatureinterface
Notice: Available only in thev=beta channel.
An interface representing a feature from a Dataset. ThefeatureType of aDatasetFeature will always beFeatureType.DATASET.
This interface extendsFeature.
Properties | |
|---|---|
datasetAttributes | Type: Object<string, string>Key-value mapping of the feature's attributes. |
datasetId | Type: stringDataset id of the dataset that this feature belongs to. |
Inherited:featureType | |
FeatureMouseEventinterface
google.maps.FeatureMouseEventinterface
This object is returned from a mouse event on aFeatureLayer.
This interface extendsMapMouseEvent.
Properties | |
|---|---|
features | The Features at this mouse event. |
Inherited:domEvent,latLng | |
Methods | |
|---|---|
Inherited:stop |
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-11-21 UTC.