googlemaps / googlemaps/js-markerclusterer

[Markers] Using AdvancedMarkerElement with a `lat` or `lng` of 0 results in it not being drawn.

Open
#722 1 comment 4 reactions 0 assignees View on GitHub
good first issue type: bug
Dominant language
TypeScript
Stars
293
Forks
104
Avg merge
3m
Merged PRs (30d)
18

Description

#### Steps to reproduce

1. Create a map, clusterer and an AdvancedMarkerElement
2. Set the marker's latitude, longitude or both to be 0
3. Pass marker to clusterer

#### Code example

```typescript
const marker = new google.maps.marker.AdvancedMarkerElement({
position: { lat: 0, lng: 1 },
title: 'Hi',
});

markers.push(marker);
});

new MarkerClusterer({
markers,
map: this.map,
renderer: new ClusterRenderer(),
});
```

Nothing on my map :(

I'm pretty sure this condition from the `MarkerUtils` is the culprit

```typescript
if (marker.position.lat && marker.position.lng) {
return new google.maps.LatLng(
marker.position.lat,
marker.position.lng
);
}
```

and might be fixed by instead doing

```typescript
if ('lat' in marker.position && 'lng' in marker.position) {
return new google.maps.LatLng(
marker.position.lat,
marker.position.lng
);
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.