Skip to content

Commit 17ab387

Browse files
committed
feat(google-maps): add google-map component
Change default location to Colossem, change map element view child to not be a stream. Minor style changes.
1 parent 4ed0038 commit 17ab387

File tree

3 files changed

+14
-19
lines changed

3 files changed

+14
-19
lines changed
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
<div *ngIf="ready">
2-
<google-map></google-map>
3-
</div>
1+
<google-map *ngIf="ready"></google-map>

src/google-maps/google-map/google-map.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import {createMapConstructorSpy, createMapSpy} from './testing/fake-google-map-u
66
import {GoogleMapModule} from './index';
77

88
const DEFAULT_OPTIONS: google.maps.MapOptions = {
9-
center: {lat: 50, lng: 50},
10-
zoom: 4,
9+
center: {lat: 41.890150, lng: 12.492231},
10+
zoom: 16,
1111
};
1212

1313
describe('GoogleMap', () => {

src/google-maps/google-map/google-map.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
ViewChild,
88
} from '@angular/core';
99
import {ReplaySubject} from 'rxjs';
10-
import {take} from 'rxjs/operators';
1110

1211
/**
1312
* Angular component that renders a Google Map via the Google Maps JavaScript
@@ -20,30 +19,28 @@ import {take} from 'rxjs/operators';
2019
template: '<div #map></div>',
2120
})
2221
export class GoogleMap implements OnInit {
22+
// Arbitrarily chosen default size
2323
@Input() height = '500px';
2424
@Input() width = '500px';
25+
2526
// TODO(mbehrlich): add options, handlers, properties, and methods.
2627

27-
@ViewChild('map', {static: true}) set mapEl(mapEl: ElementRef) {
28-
this._mapEl$.next(mapEl);
29-
}
28+
@ViewChild('map', {static: true}) mapElRef: ElementRef;
3029

31-
private readonly _mapEl$ = new ReplaySubject<ElementRef>(1);
3230
private readonly _map$ = new ReplaySubject<google.maps.Map>(1);
3331

3432
ngOnInit() {
3533
// default options for now
3634
const options: google.maps.MapOptions = {
37-
center: {lat: 50, lng: 50},
38-
zoom: 4,
35+
center: {lat: 41.890150, lng: 12.492231},
36+
zoom: 16,
3937
};
4038

41-
this._mapEl$.pipe(take(1)).subscribe(mapElRef => {
42-
const mapEl = mapElRef.nativeElement;
43-
mapEl.style.height = this.height;
44-
mapEl.style.width = this.width;
45-
const map = new google.maps.Map(mapEl, options);
46-
this._map$.next(map);
47-
});
39+
40+
const mapEl = this.mapElRef.nativeElement;
41+
mapEl.style.height = this.height;
42+
mapEl.style.width = this.width;
43+
const map = new google.maps.Map(mapEl, options);
44+
this._map$.next(map);
4845
}
4946
}

0 commit comments

Comments
 (0)