Skip to content

Commit 414e4b7

Browse files
committed
feat(google-maps): add google-map component
Fix lint issues. Fix overviews bazel rule typo.
1 parent 6b99c61 commit 414e4b7

File tree

8 files changed

+85
-67
lines changed

8 files changed

+85
-67
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@
140140
/src/dev-app/expansion/** @josephperrott
141141
/src/dev-app/focus-origin/** @mmalerba
142142
/src/dev-app/gestures/** @jelbourn
143+
/src/dev-app/google-map/** @mbehrlich
143144
/src/dev-app/grid-list/** @jelbourn
144145
/src/dev-app/icon/** @jelbourn
145146
/src/dev-app/input/** @mmalerba

src/google-maps/BUILD.bazel

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,29 @@ load("//tools:defaults.bzl", "ng_module", "ng_package")
55

66
# Root "@angular/google-maps" entry-point that does not re-export individual entry-points.
77
ng_module(
8-
name = "google-maps",
9-
srcs = glob(
10-
["*.ts"],
11-
exclude = ["**/*.spec.ts"],
12-
),
13-
module_name = "@angular/google-maps",
14-
deps = [
15-
"@npm//@angular/core",
16-
"@npm//@types/googlemaps",
17-
],
8+
name = "google-maps",
9+
srcs = glob(
10+
["*.ts"],
11+
exclude = ["**/*.spec.ts"],
12+
),
13+
module_name = "@angular/google-maps",
14+
deps = [
15+
"@npm//@angular/core",
16+
"@npm//@types/googlemaps",
17+
],
1818
)
1919

2020
filegroup(
21-
name = "overviews",
22-
srcs = ["//src/material/%s:overview" % name for name in GOOGLE_MAPS_PACKAGES],
21+
name = "overviews",
22+
srcs = ["//src/google-maps/%s:overview" % name for name in GOOGLE_MAPS_PACKAGES],
2323
)
2424

2525
# Creates the @angular/google-maps package published to npm
2626
ng_package(
27-
name = "npm_package",
28-
srcs = ["package.json"],
29-
entry_point = ":public-api.ts",
30-
entry_point_name = "google-maps",
31-
globals = ROLLUP_GLOBALS,
32-
deps = GOOGLE_MAPS_TARGETS,
27+
name = "npm_package",
28+
srcs = ["package.json"],
29+
entry_point = ":public-api.ts",
30+
entry_point_name = "google-maps",
31+
globals = ROLLUP_GLOBALS,
32+
deps = GOOGLE_MAPS_TARGETS,
3333
)

src/google-maps/google-map/BUILD.bazel

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,48 @@ load(
44
"//tools:defaults.bzl",
55
"markdown_to_html",
66
"ng_module",
7-
"ng_package",
87
"ng_test_library",
98
"ng_web_test_suite",
109
)
1110

1211
ng_module(
13-
name = "google-map",
14-
srcs = glob(
15-
["**/*.ts"],
16-
exclude = ["**/*.spec.ts"],
17-
),
18-
module_name = "@angular/google-maps/google-map",
19-
deps = [
20-
"@npm//@angular/core",
21-
"@npm//@types/googlemaps",
22-
"@npm//rxjs",
23-
],
12+
name = "google-map",
13+
srcs = glob(
14+
["**/*.ts"],
15+
exclude = ["**/*.spec.ts"],
16+
),
17+
module_name = "@angular/google-maps/google-map",
18+
deps = [
19+
"@npm//@angular/core",
20+
"@npm//@types/googlemaps",
21+
"@npm//rxjs",
22+
],
2423
)
2524

2625
ng_test_library(
27-
name = "unit_test_sources",
28-
srcs = glob(
29-
["**/*.spec.ts"],
30-
exclude = ["**/*.e2e.spec.ts"],
31-
),
32-
deps = [
33-
":google-map",
34-
"//src/google-maps/google-map/testing",
35-
"@npm//@angular/platform-browser",
36-
],
26+
name = "unit_test_sources",
27+
srcs = glob(
28+
["**/*.spec.ts"],
29+
exclude = ["**/*.e2e.spec.ts"],
30+
),
31+
deps = [
32+
":google-map",
33+
"//src/google-maps/google-map/testing",
34+
"@npm//@angular/platform-browser",
35+
],
3736
)
3837

3938
ng_web_test_suite(
40-
name = "unit_tests",
41-
deps = [":unit_test_sources"],
39+
name = "unit_tests",
40+
deps = [":unit_test_sources"],
4241
)
4342

4443
markdown_to_html(
45-
name = "overview",
46-
srcs = [":google-map.md"],
44+
name = "overview",
45+
srcs = [":google-map.md"],
4746
)
4847

4948
filegroup(
50-
name = "source-files",
51-
srcs = glob(["**/*.ts"]),
49+
name = "source-files",
50+
srcs = glob(["**/*.ts"]),
5251
)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import {Component} from '@angular/core';
2-
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
2+
import {async, TestBed} from '@angular/core/testing';
33
import {By} from '@angular/platform-browser';
44

55
import {createMapConstructorSpy, createMapSpy} from './testing/fake-google-map-utils';
6-
import {GoogleMap, GoogleMapModule} from './index';
6+
import {GoogleMapModule} from './index';
77

88
const DEFAULT_OPTIONS: google.maps.MapOptions = {
99
center: {lat: 50, lng: 50},
Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1-
import {ChangeDetectionStrategy, Component, ElementRef, Input, OnInit, ViewChild} from '@angular/core';
2-
import {combineLatest, ReplaySubject} from 'rxjs';
1+
import {
2+
ChangeDetectionStrategy,
3+
Component,
4+
ElementRef,
5+
Input,
6+
OnInit,
7+
ViewChild,
8+
} from '@angular/core';
9+
import {ReplaySubject} from 'rxjs';
310
import {take} from 'rxjs/operators';
411

12+
/**
13+
* Angular component that renders a Google Map via the Google Maps JavaScript
14+
* API.
15+
* @see https://developers.google.com/maps/documentation/javascript/reference/
16+
*/
517
@Component({
618
selector: 'google-map',
719
changeDetection: ChangeDetectionStrategy.OnPush,
@@ -10,14 +22,14 @@ import {take} from 'rxjs/operators';
1022
export class GoogleMap implements OnInit {
1123
@Input() height = '500px';
1224
@Input() width = '500px';
13-
//TODO(mbehrlich): add options, handlers, properties, and methods.
25+
// TODO(mbehrlich): add options, handlers, properties, and methods.
1426

15-
@ViewChild('map', {static: true}) set _mapEl(mapEl: ElementRef) {
16-
this.mapEl$.next(mapEl);
27+
@ViewChild('map', {static: true}) set mapEl(mapEl: ElementRef) {
28+
this._mapEl$.next(mapEl);
1729
}
1830

19-
private readonly mapEl$ = new ReplaySubject<ElementRef>(1);
20-
private readonly map$ = new ReplaySubject<google.maps.Map>(1);
31+
private readonly _mapEl$ = new ReplaySubject<ElementRef>(1);
32+
private readonly _map$ = new ReplaySubject<google.maps.Map>(1);
2133

2234
ngOnInit() {
2335
// default options for now
@@ -26,12 +38,12 @@ export class GoogleMap implements OnInit {
2638
zoom: 4,
2739
};
2840

29-
this.mapEl$.pipe(take(1)).subscribe(mapElRef => {
41+
this._mapEl$.pipe(take(1)).subscribe(mapElRef => {
3042
const mapEl = mapElRef.nativeElement;
3143
mapEl.style.height = this.height;
3244
mapEl.style.width = this.width;
3345
const map = new google.maps.Map(mapEl, options);
34-
this.map$.next(map);
46+
this._map$.next(map);
3547
});
3648
}
3749
}

src/google-maps/google-map/testing/BUILD.bazel

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ package(default_visibility = ["//visibility:public"])
33
load("//tools:defaults.bzl", "ts_library")
44

55
ts_library(
6-
name = "testing",
7-
testonly = 1,
8-
srcs = glob(["**/*.ts"]),
9-
deps = [
10-
"@npm//@types/jasmine",
11-
"@npm//@types/googlemaps",
12-
],
6+
name = "testing",
7+
testonly = 1,
8+
srcs = glob(["**/*.ts"]),
9+
deps = [
10+
"@npm//@types/googlemaps",
11+
"@npm//@types/jasmine",
12+
],
1313
)

src/google-maps/google-map/testing/fake-google-map-utils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
declare global {
22
interface Window {
3-
google?: {maps: {Map: jasmine.Spy;}};
3+
google?: {
4+
maps: {
5+
Map: jasmine.Spy;
6+
};
7+
};
48
}
59
}
610

tools/package-tools/rollup-globals.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ const cdkSecondaryEntryPoints = getSubdirectoryNames(join(buildConfig.packagesDi
2323
const matSecondaryEntryPoints = getSubdirectoryNames(join(buildConfig.packagesDir, 'material'));
2424

2525
/** List of potential secondary entry-points for the google-maps package. */
26-
const googleMapsSecondaryEntryPoints = getSubdirectoryNames(join(buildConfig.packagesDir, 'google-maps'));
26+
const googleMapsSecondaryEntryPoints =
27+
getSubdirectoryNames(join(buildConfig.packagesDir, 'google-maps'));
2728

2829
/** List of potential secondary entry-points for the cdk-experimental package. */
2930
const cdkExperimentalSecondaryEntryPoints =
@@ -44,7 +45,8 @@ const rollupCdkEntryPoints = generateRollupEntryPoints('cdk', cdkSecondaryEntryP
4445
const rollupMatEntryPoints = generateRollupEntryPoints('material', matSecondaryEntryPoints);
4546

4647
/** Object with all google-maps entry points in the format of Rollup globals. */
47-
const rollupGoogleMapsEntryPoints = generateRollupEntryPoints('google-maps', googleMapsSecondaryEntryPoints);
48+
const rollupGoogleMapsEntryPoints =
49+
generateRollupEntryPoints('google-maps', googleMapsSecondaryEntryPoints);
4850

4951
/** Object with all material-experimental entry points in the format of Rollup globals. */
5052
const rollupMaterialExperimentalEntryPoints =

0 commit comments

Comments
 (0)