Skip to content

Commit c8ceae5

Browse files
mbehrlichjelbourn
authored andcommitted
feat(google-maps): add map-marker component (#16964)
* Refactor google-maps module to have a single entry-point, @angular/google-maps, instead of a separate one for every component. * Add GoogleMap and MapMarker components to index for the google maps module.
1 parent 44b8a47 commit c8ceae5

28 files changed

+913
-126
lines changed

packages.bzl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,6 @@ MATERIAL_SCSS_LIBS = [
8080
for p in MATERIAL_PACKAGES
8181
]
8282

83-
GOOGLE_MAPS_PACKAGES = [
84-
"google-map",
85-
]
86-
87-
GOOGLE_MAPS_TARGETS = ["//src/google-maps"] + ["//src/google-maps/%s" % p for p in GOOGLE_MAPS_PACKAGES]
88-
8983
MATERIAL_EXPERIMENTAL_PACKAGES = [
9084
"mdc-button",
9185
"mdc-card",

src/dev-app/google-map/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ng_module(
77
srcs = glob(["**/*.ts"]),
88
assets = ["google-map-demo.html"],
99
deps = [
10-
"//src/google-maps/google-map",
10+
"//src/google-maps",
1111
"@npm//@angular/router",
1212
],
1313
)

src/dev-app/google-map/google-map-demo-module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
import {CommonModule} from '@angular/common';
1010
import {HttpClientJsonpModule, HttpClientModule} from '@angular/common/http';
1111
import {NgModule} from '@angular/core';
12-
import {GoogleMapModule} from '@angular/google-maps/google-map';
12+
import {GoogleMapsModule} from '@angular/google-maps';
1313
import {RouterModule} from '@angular/router';
1414

1515
import {GoogleMapDemo} from './google-map-demo';
1616

1717
@NgModule({
1818
imports: [
1919
CommonModule,
20-
GoogleMapModule,
20+
GoogleMapsModule,
2121
HttpClientJsonpModule,
2222
HttpClientModule,
2323
RouterModule.forChild([{path: '', component: GoogleMapDemo}]),

src/dev-app/google-map/google-map-demo.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@
44
[center]="center"
55
[zoom]="zoom"
66
(mapClick)="handleClick($event)"
7-
(mapMousemove)="handleMove($event)"></google-map>
7+
(mapMousemove)="handleMove($event)"
8+
(mapRightclick)="handleRightclick()">
9+
<map-marker></map-marker>
10+
<map-marker *ngFor="let markerPosition of markerPositions"
11+
[position]="markerPosition"
12+
[options]="markerOptions"
13+
(mapClick)="clickMarker($event)"></map-marker>
14+
</google-map>
815

916
<div>Latitude: {{display?.lat}}</div>
1017
<div>Longitude: {{display?.lng}}</div>

src/dev-app/google-map/google-map-demo.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export class GoogleMapDemo {
1919
isReady = false;
2020

2121
center = {lat: 24, lng: 12};
22+
markerOptions = {draggable: false};
23+
markerPositions: google.maps.LatLngLiteral[] = [];
2224
zoom = 4;
2325
display?: google.maps.LatLngLiteral;
2426

@@ -30,10 +32,19 @@ export class GoogleMapDemo {
3032
}
3133

3234
handleClick(event: google.maps.MouseEvent) {
33-
this.center = event.latLng.toJSON();
35+
this.markerPositions.push(event.latLng.toJSON());
3436
}
3537

3638
handleMove(event: google.maps.MouseEvent) {
3739
this.display = event.latLng.toJSON();
3840
}
41+
42+
clickMarker(event: google.maps.MouseEvent) {
43+
console.log(this.markerOptions);
44+
this.markerOptions = {draggable: true};
45+
}
46+
47+
handleRightclick() {
48+
this.markerPositions.pop();
49+
}
3950
}

src/dev-app/system-config.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ var MATERIAL_PACKAGES = [
5555
'tree',
5656
];
5757

58-
var GOOGLE_MAPS_PACKAGES = [
59-
'google-map',
60-
];
61-
6258
var MATERIAL_EXPERIMENTAL_PACKAGES = [
6359
'mdc-button',
6460
'mdc-card',
@@ -103,9 +99,7 @@ MATERIAL_EXPERIMENTAL_PACKAGES.forEach(function(pkgName) {
10399
MATERIAL_PACKAGES.forEach(function(pkgName) {
104100
configureEntryPoint('material', pkgName);
105101
});
106-
GOOGLE_MAPS_PACKAGES.forEach(function(pkgName) {
107-
configureEntryPoint('google-maps', pkgName);
108-
});
102+
configureEntryPoint('google-maps');
109103
configureEntryPoint('youtube-player');
110104

111105
/** Configures the specified package and its entry-point. */

src/dev-app/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"@angular/cdk-experimental/*": ["../cdk-experimental/*"],
1515
"@angular/cdk-experimental": ["../cdk-experimental"],
1616
"@angular/material-moment-adapter": ["../material-moment-adapter/public-api.ts"],
17-
"@angular/google-maps/*": ["../google-maps/*"],
17+
"@angular/google-maps": ["../google-maps"],
1818
"@angular/material-examples": ["../../dist/packages/material-examples"]
1919
}
2020
},

src/google-maps/BUILD.bazel

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
11
package(default_visibility = ["//visibility:public"])
22

3-
load("//:packages.bzl", "GOOGLE_MAPS_PACKAGES", "GOOGLE_MAPS_TARGETS", "ROLLUP_GLOBALS")
3+
load("//:packages.bzl", "ROLLUP_GLOBALS")
44
load("//tools:defaults.bzl", "ng_module", "ng_package")
55

6-
# Root "@angular/google-maps" entry-point that does not re-export individual entry-points.
76
ng_module(
87
name = "google-maps",
98
srcs = glob(
109
["*.ts"],
1110
exclude = ["**/*.spec.ts"],
1211
),
1312
module_name = "@angular/google-maps",
14-
deps = ["//src/google-maps/%s" % p for p in GOOGLE_MAPS_PACKAGES] + [
13+
deps = [
14+
"//src/google-maps/google-map",
15+
"//src/google-maps/map-marker",
1516
"@npm//@angular/core",
1617
"@npm//@types/googlemaps",
1718
],
1819
)
1920

20-
filegroup(
21-
name = "overviews",
22-
srcs = ["//src/google-maps/%s:overview" % name for name in GOOGLE_MAPS_PACKAGES],
23-
)
24-
2521
# Creates the @angular/google-maps package published to npm
2622
ng_package(
2723
name = "npm_package",
2824
srcs = ["package.json"],
2925
entry_point = ":public-api.ts",
3026
entry_point_name = "google-maps",
3127
globals = ROLLUP_GLOBALS,
32-
deps = GOOGLE_MAPS_TARGETS,
28+
deps = [":google-maps"],
29+
)
30+
31+
filegroup(
32+
name = "source-files",
33+
srcs = glob(["**/*.ts"]),
3334
)

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package(default_visibility = ["//visibility:public"])
22

33
load(
44
"//tools:defaults.bzl",
5-
"markdown_to_html",
65
"ng_module",
76
"ng_test_library",
87
"ng_web_test_suite",
@@ -14,8 +13,8 @@ ng_module(
1413
["**/*.ts"],
1514
exclude = ["**/*.spec.ts"],
1615
),
17-
module_name = "@angular/google-maps/google-map",
1816
deps = [
17+
"//src/google-maps/map-marker",
1918
"@npm//@angular/core",
2019
"@npm//@types/googlemaps",
2120
"@npm//rxjs",
@@ -30,7 +29,8 @@ ng_test_library(
3029
),
3130
deps = [
3231
":google-map",
33-
"//src/google-maps/google-map/testing",
32+
"//src/google-maps/map-marker",
33+
"//src/google-maps/testing",
3434
"@npm//@angular/platform-browser",
3535
],
3636
)
@@ -40,11 +40,6 @@ ng_web_test_suite(
4040
deps = [":unit_test_sources"],
4141
)
4242

43-
markdown_to_html(
44-
name = "overview",
45-
srcs = [":google-map.md"],
46-
)
47-
4843
filegroup(
4944
name = "source-files",
5045
srcs = glob(["**/*.ts"]),

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {NgModule} from '@angular/core';
10-
import {GoogleMap} from './google-map';
9+
import {NgModule} from '@angular/core';
1110

12-
@NgModule({
13-
exports: [GoogleMap],
14-
declarations: [GoogleMap],
15-
})
16-
export class GoogleMapModule {}
11+
import {GoogleMap} from './google-map';
12+
13+
@NgModule({
14+
exports: [GoogleMap],
15+
declarations: [GoogleMap],
16+
})
17+
export class GoogleMapModule {
18+
}

0 commit comments

Comments
 (0)