Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions src/marker-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,26 @@
*/

export class MarkerUtils {
public static isAdvancedMarker(marker: Marker): boolean {
if (
public static isAdvancedMarker(
marker: Marker
): marker is google.maps.marker.AdvancedMarkerElement {
return (
google.maps.marker &&
marker instanceof google.maps.marker.AdvancedMarkerElement
) {
return true;
}
return false;
);
}

public static setMap(marker: Marker, map: google.maps.Map | null) {
if (this.isAdvancedMarker(marker)) {
(marker as google.maps.marker.AdvancedMarkerElement).map = map;
return;
marker.map = map;
} else {
(marker as google.maps.Marker).setMap(map);
}
(marker as google.maps.Marker).setMap(map);
}

public static getPosition(marker: Marker): google.maps.LatLng {
// SuperClusterAlgorithm.calculate expects a LatLng instance so we fake it for Adv Markers
if (this.isAdvancedMarker(marker)) {
marker = marker as google.maps.marker.AdvancedMarkerElement;
if (marker.position) {
if (marker.position instanceof google.maps.LatLng) {
return marker.position;
Expand Down