Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions src/google-maps/map-directions-renderer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,26 @@ Using the `MapDirectionsService` requires the Directions API to be enabled in Go

```typescript
// google-maps-demo.component.ts
import {Component} from '@angular/core';
import {Component, inject} from '@angular/core';
import {GoogleMap, MapDirectionsRenderer, MapDirectionsService} from '@angular/google-maps';
import {map} from 'rxjs/operators';

@Component({
selector: 'google-map-demo',
templateUrl: 'google-map-demo.html',
imports: [GoogleMap, MapDirectionsRenderer],
imports: [GoogleMap, MapDirectionsRenderer],
})
export class GoogleMapDemo {
center: google.maps.LatLngLiteral = {lat: 24, lng: 12};
zoom = 4;

readonly directionsResults$: Observable<google.maps.DirectionsResult|undefined>;
private mapDirectionsService = inject(MapDirectionsService);

constructor(mapDirectionsService: MapDirectionsService) {
const request: google.maps.DirectionsRequest = {
destination: {lat: 12, lng: 4},
origin: {lat: 14, lng: 8},
travelMode: google.maps.TravelMode.DRIVING
};
this.directionsResults$ = mapDirectionsService.route(request).pipe(map(response => response.result));
}
readonly directionsResults$ = this.mapDirectionsService.route({
destination: {lat: 12, lng: 4},
origin: {lat: 14, lng: 8},
travelMode: google.maps.TravelMode.DRIVING,
}).pipe(map(response => response.result));
}
```

Expand Down
8 changes: 5 additions & 3 deletions src/google-maps/map-geocoder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,18 @@ has billing enabled. See [here](https://developers.google.com/maps/documentation

```typescript
// google-maps-demo.component.ts
import {Component} from '@angular/core';
import {Component, inject} from '@angular/core';
import {MapGeocoder} from '@angular/google-maps';

@Component({
selector: 'google-map-demo',
templateUrl: 'google-map-demo.html',
})
export class GoogleMapDemo {
constructor(geocoder: MapGeocoder) {
geocoder.geocode({
private geocoder = inject(MapGeocoder);

search() {
this.geocoder.geocode({
address: '1600 Amphitheatre Parkway, Mountain View, CA'
}).subscribe(({results}) => {
console.log(results);
Expand Down