| Property | Description |
|---|---|
title |
Sets the title, visible on hover |
position |
Sets the position |
label |
Sets the label |
clickable |
If the marker should listen to mouse and touch events, default is true |
options |
Sets the options, for more info see the [docs](https://developers. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class AppComponent implements OnInit { | |
| addMarker() { | |
| this.markers.push({ | |
| position: { | |
| lat: this.center.lat + ((Math.random() - 0.5) * 2) / 10, | |
| lng: this.center.lng + ((Math.random() - 0.5) * 2) / 10, | |
| }, | |
| label: { | |
| color: 'red', | |
| text: 'Marker label ' + (this.markers.length + 1), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <google-map> | |
| <map-marker | |
| *ngFor="let marker of markers" | |
| [position]="marker.position" | |
| [label]="marker.label" | |
| [title]="marker.title" | |
| [options]="marker.options" | |
| > | |
| </map-marker> | |
| </google-map> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class AppComponent implements OnInit { | |
| @ViewChild(MapInfoWindow, { static: false }) info: MapInfoWindow | |
| logCenter() { | |
| console.log(JSON.stringify(this.map.getCenter())) | |
| } | |
| } |
| Function | Description |
|---|---|
fitBounds |
Sets the viewport to contain the given bounds |
panBy |
Changes the center of the map by the given distance in pixels |
panTo |
Changes the center of the map to the given LatLng |
panToBounds |
Pans the map by the minimum amount necessary to contain the given LatLngBounds |
getBounds |
Returns the lat/lng bounds of the current viewport |
getCenter |
Returns the position displa |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class AppComponent implements OnInit { | |
| click(event: google.maps.MouseEvent) { | |
| console.log(event) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <google-map (mapClick)="click($event)"></google-map> |
| Property | JavaScript API Method | Description |
|---|---|---|
boundsChanged |
bounds_changed |
This event is fired when the viewport bounds have changed |
centerChanged |
center_changed |
This event is fired when the map center property changes |
mapClick |
click |
This event is fired when the user clicks on the map |
mapDblclick |
dblclick |
This event is fired when the user double-clicks on the map. Note that the click event will also fire, righ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class AppComponent implements OnInit { | |
| zoom = 12 | |
| center: google.maps.LatLngLiteral | |
| options: google.maps.MapOptions = { | |
| mapTypeId: 'hybrid', | |
| zoomControl: false, | |
| scrollwheel: false, | |
| disableDoubleClickZoom: true, | |
| maxZoom: 15, | |
| minZoom: 8, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <google-map></google-map> |