Skip to content

Commit 897af65

Browse files
authored
fix: Update index.ts (#453)
1 parent 9c047cc commit 897af65

File tree

1 file changed

+7
-1
lines changed
  • samples/ui-kit-place-search-text

1 file changed

+7
-1
lines changed

samples/ui-kit-place-search-text/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ async function addMarkers(){
8484

8585
const bounds = new LatLngBounds();
8686

87+
// First remove all existing markers.
88+
for(marker in markers){
89+
markers[marker].map = null;
90+
}
91+
markers = {};
92+
8793
if(placeList.places.length > 0){
8894
placeList.places.forEach((place) => {
8995
let marker = new AdvancedMarkerElement({
@@ -125,4 +131,4 @@ async function addMarkers(){
125131
/* [END maps_ui_kit_place_search_text_add_markers] */
126132

127133
initMap();
128-
/* [END maps_ui_kit_place_search_text] */
134+
/* [END maps_ui_kit_place_search_text] */

0 commit comments

Comments
 (0)