Skip to content

Commit 5a490cc

Browse files
author
apixandru
committed
markers stay cached
1 parent facd027 commit 5a490cc

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
(mapClick)="handleClick($event)"
99
(mapMousemove)="handleMove($event)"
1010
(mapRightclick)="handleRightclick()"
11+
[options]="createOptions"
1112
[mapTypeId]="mapTypeId">
1213
<map-marker-clusterer [imagePath]="markerClustererImagePath">
13-
<map-marker #firstMarker="mapMarker"
14-
[position]="center"
15-
(mapClick)="clickMarker(firstMarker)"></map-marker>
14+
<!-- <map-marker #firstMarker="mapMarker"-->
15+
<!-- [position]="center"-->
16+
<!-- (mapClick)="clickMarker(firstMarker)"></map-marker>-->
1617
@for (markerPosition of markerPositions; track markerPosition) {
1718
<map-marker #marker="mapMarker"
1819
[position]="markerPosition"
@@ -70,6 +71,13 @@
7071
<p><label>Latitude:</label> {{display?.lat}}</p>
7172
<p><label>Longitude:</label> {{display?.lng}}</p>
7273

74+
<div>
75+
<label for="polyline-checkbox">
76+
Hide markers
77+
<input type="checkbox" (click)="toggleHideMarkers()">
78+
</label>
79+
</div>
80+
7381
<div>
7482
<label for="map-type">
7583
Select map type

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

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,13 @@ export class GoogleMapDemo {
9191
center = {lat: 24, lng: 12};
9292
mapAdvancedMarkerPosition = {lat: 24, lng: 16};
9393
markerOptions = {draggable: false};
94-
markerPositions: google.maps.LatLngLiteral[] = [];
94+
markerPositions: google.maps.LatLngLiteral[] = [this.center];
95+
markerPositionsOld: google.maps.LatLngLiteral[] = [];
96+
advancedMarkerPositions: google.maps.LatLngLiteral[] = [this.mapAdvancedMarkerPosition];
97+
advancedMarkerPositionsOld: google.maps.LatLngLiteral[] = [];
98+
99+
hidden: boolean = false;
100+
95101
zoom = 4;
96102
display?: google.maps.LatLngLiteral;
97103
isPolylineDisplayed = false;
@@ -101,6 +107,11 @@ export class GoogleMapDemo {
101107
strokeOpacity: 0.8,
102108
};
103109

110+
createOptions: google.maps.MapOptions = {
111+
gestureHandling: 'greedy',
112+
mapId: '* YOUR MAP ID *',
113+
};
114+
104115
heatmapData = this._getHeatmapData(5, 1);
105116
heatmapOptions = {radius: 50};
106117
isHeatmapDisplayed = false;
@@ -319,4 +330,18 @@ export class GoogleMapDemo {
319330
document.body.appendChild(script);
320331
});
321332
}
333+
334+
toggleHideMarkers() {
335+
if (this.hidden) {
336+
this.advancedMarkerPositions = this.advancedMarkerPositionsOld;
337+
this.markerPositions = this.markerPositionsOld;
338+
this.hidden = false;
339+
} else {
340+
this.advancedMarkerPositionsOld = this.advancedMarkerPositions;
341+
this.advancedMarkerPositions = [];
342+
this.markerPositionsOld = this.markerPositions;
343+
this.markerPositions = [];
344+
this.hidden = true;
345+
}
346+
}
322347
}

0 commit comments

Comments
 (0)