-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(google-maps): add readme (#29898)
* docs(google-maps/map-advanced-marker): README.md added * Update README.md Removed list of inputs and corrected spelling. * Update README.md (cherry picked from commit a2dc657)
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# MapAdvancedMarker | ||
|
||
The `MapAdvancedMarker` component wraps the [`google.maps.marker.AdvancedMarkerElement` class](https://developers.google.com/maps/documentation/javascript/reference/advanced-markers) from the Google Maps JavaScript API. The `MapAdvancedMarker` component displays a marker on the map when it is a content child of a `GoogleMap` component. | ||
|
||
**Note:** Use of `map-advanced-marker` requires a `google-map` with a valid `mapId`. | ||
|
||
## Example | ||
|
||
```typescript | ||
// google-map-demo.component.ts | ||
import {Component} from '@angular/core'; | ||
import {GoogleMap, MapAdvancedMarker} from '@angular/google-maps'; | ||
|
||
@Component({ | ||
selector: 'google-map-demo', | ||
templateUrl: 'google-map-demo.html', | ||
imports: [GoogleMap, MapAdvancedMarker], | ||
}) | ||
export class GoogleMapDemo { | ||
center: google.maps.LatLngLiteral = {lat: 24, lng: 12}; | ||
zoom = 4; | ||
advancedMarkerOptions: google.maps.marker.AdvancedMarkerElementOptions = {gmpDraggable: false}; | ||
advancedMarkerPositions: google.maps.LatLngLiteral[] = []; | ||
|
||
addAdvancedMarker(event: google.maps.MapMouseEvent) { | ||
this.advancedMarkerPositions.push(event.latLng.toJSON()); | ||
} | ||
} | ||
``` | ||
|
||
```html | ||
<!-- google-map-demo.component.html --> | ||
<google-map | ||
mapId="yourMapId" | ||
height="400px" | ||
width="750px" | ||
[center]="center" | ||
[zoom]="zoom" | ||
(mapClick)="addAdvancedMarker($event)"> | ||
@for (position of advancedMarkerPositions; track position) { | ||
<map-advanced-marker [position]="position" [options]="advancedMarkerOptions" /> | ||
} | ||
</google-map> | ||
``` |