Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MarkerIcon type #1836

Merged
7 commits merged into from
Jul 16, 2020
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion packages/core/directives/marker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class AgmMarker implements OnDestroy, OnChanges, AfterContentInit, FitBou
/**
* Icon (the URL of the image) for the foreground.
*/
@Input() iconUrl: string;
@Input() iconUrl: string | mapTypes.MarkerIcon | mapTypes.GoogleSymbol;

/**
* If true, the marker is visible
Expand Down
2 changes: 2 additions & 0 deletions packages/core/map-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export {
LatLngLiteral,
PolyMouseEvent,
MarkerLabel,
MarkerIcon,
Geocoder,
GeocoderAddressComponent,
GeocoderComponentRestrictions,
Expand Down Expand Up @@ -42,6 +43,7 @@ export {
RectangleOptions,
Marker,
MarkerOptions,
GoogleSymbol,
} from './services/google-maps-types';

/**
Expand Down
11 changes: 10 additions & 1 deletion packages/core/services/google-maps-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export interface MarkerOptions {
map?: GoogleMap;
label?: string | MarkerLabel;
draggable?: boolean;
icon?: string;
icon?: string | MarkerIcon;
darron1217 marked this conversation as resolved.
Show resolved Hide resolved
opacity?: number;
visible?: boolean;
zIndex?: number;
Expand All @@ -82,6 +82,15 @@ export interface MarkerLabel {
text: string;
}

export interface MarkerIcon {
darron1217 marked this conversation as resolved.
Show resolved Hide resolved
anchor?: any | Point;
darron1217 marked this conversation as resolved.
Show resolved Hide resolved
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are all of these typed any | Something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's because interface props without ? causes compile error.
For example, Size interface checks every prop exists even if I just want to use width & height

export interface Size {
    height: number;
    width: number;
    equals(other: Size): boolean;
    toString(): string;
}

I wanted to add question mark on every props of Size, but I just picked other solution.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because Size is a class, not a literal interface. Google Maps API doesn't just support {width: 100, height: 200} . You're supposed to use their provided class with constructor. https://developers.google.com/maps/documentation/javascript/reference/coordinates#Size

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, I was using it in a wrong way

labelOrigin?: any | Point;
origin?: any | Point;
scaledSize?: any | Size;
size?: any | Size;
url: string;
}

export interface Circle extends MVCObject {
getBounds(): LatLngBounds;
getCenter(): LatLng;
Expand Down