MapElement class
google.maps.MapElement
class
MapElement is an HTMLElement
subclass for rendering maps. After loading the maps
library, a map can be created in HTML. For example:
<gmp-map center="37.4220656,-122.0840897" zoom="10" map-id="DEMO_MAP_ID">
<button slot="control-block-start-inline-end">Custom Control</button>
</gmp-map>
Internally, it uses
Map
, which can be accessed with the MapElement.innerMap
property.
Custom element:
<gmp-map center="lat,lng" heading-interaction-disabled internal-usage-attribution-ids="id1 id2" map-id="string" rendering-type="vector" tilt-interaction-disabled zoom="number"></gmp-map>
This class extends
HTMLElement
.
This class implements
MapElementOptions
.
Access by calling const {MapElement} = await google.maps.importLibrary("maps")
.
See Libraries in the Maps JavaScript API.
Constructor | |
---|---|
MapElement |
MapElement([options]) Parameters:
|
Properties | |
---|---|
center |
Type:
LatLng|LatLngLiteral optional The center latitude/longitude of the map.
HTML attribute:
|
headingInteractionDisabled |
Type:
boolean optional Default:
false Whether the map should allow user control of the camera heading (rotation). This option is only in effect when the map is a vector map. If not set in code, then the cloud configuration for the map ID will be used (if available).
HTML attribute:
|
innerMap |
Type:
Map A reference to the Map that the MapElement uses internally. |
internalUsageAttributionIds |
Type:
Iterable<string> optional Default:
null Adds a usage attribution ID to the initializer, which helps Google understand which libraries and samples are helpful to developers, such as usage of a marker clustering library. To opt out of sending the usage attribution ID, it is safe to delete this property or replace the value with an empty string. Only unique values will be sent. Changes to this value after instantiation may be ignored.
HTML attribute:
|
mapId |
Type:
string optional The map ID of the map. This parameter cannot be set or changed after a map is instantiated.
Map.DEMO_MAP_ID can be used to try out features that require a map ID but which do not require cloud enablement.HTML attribute:
|
renderingType |
Type:
RenderingType optional Default:
RenderingType.VECTOR Whether the map should be a raster or vector map. This parameter cannot be set or changed after a map is instantiated. If not set, then the cloud configuration for the map ID will determine the rendering type (if available). Please note that vector maps may not be available for all devices and browsers and the map will fall back to a raster map as needed.
HTML attribute:
|
tiltInteractionDisabled |
Type:
boolean optional Default:
false Whether the map should allow user control of the camera tilt. This option is only in effect when the map is a vector map. If not set in code, then the cloud configuration for the map ID will be used (if available).
HTML attribute:
|
zoom |
Type:
number optional The zoom level of the map. Valid zoom values are numbers from zero up to the supported maximum zoom level. Larger zoom values correspond to a higher resolution.
HTML attribute:
|
Methods | |
---|---|
addEventListener |
addEventListener(type, listener[, options]) Parameters:
Return Value:
void Sets up a function that will be called whenever the specified event is delivered to the target. See addEventListener. |
removeEventListener |
removeEventListener(type, listener[, options]) Parameters:
Return Value:
void Removes an event listener previously registered with addEventListener from the target. See removeEventListener. |
Events | |
---|---|
gmp-zoomchange |
function(event) Arguments:
This event is fired when the map zoom property changes. |
MapElementOptions interface
google.maps.MapElementOptions
interface
MapElementOptions object used to define the properties that can be set on a MapElement.
Properties | |
---|---|
center optional |
Type:
LatLng|LatLngLiteral optional See MapElement.center . |
headingInteractionDisabled optional |
Type:
boolean optional |
internalUsageAttributionIds optional |
Type:
Iterable<string> optional |
mapId optional |
Type:
string optional See MapElement.mapId . |
renderingType optional |
Type:
RenderingType optional |
tiltInteractionDisabled optional |
Type:
boolean optional |
zoom optional |
Type:
number optional See MapElement.zoom . |