Skip to content

Commit

Permalink
feat(all): add containsCoordinate() static method to Projection class
Browse files Browse the repository at this point in the history
  • Loading branch information
fgutteridge committed Jan 6, 2020
1 parent 3d1ef61 commit cf5b0a7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/map-view-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ export class UISettingsBase implements UISettings {

export abstract class ProjectionBase implements Projection {
public visibleRegion: VisibleRegion;
public abstract containsCoordinate(position: Position): Boolean;
public abstract fromScreenLocation(point: Point): Position;
public abstract toScreenLocation(position: Position): Point;
public ios: any; /* GMSProjection */
Expand Down
4 changes: 4 additions & 0 deletions src/map-view.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,10 @@ export class Projection extends ProjectionBase {
return new VisibleRegion(this.android.getVisibleRegion());
}

containsCoordinate(position: Position): Boolean {
return this.android.getVisibleRegion().latLngBounds.contains(position.android);
}

fromScreenLocation(point: Point) {
var latLng = this.android.fromScreenLocation(new android.graphics.Point(point.x, point.y));
return new Position(latLng);
Expand Down
1 change: 1 addition & 0 deletions src/map-view.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export class UISettings {

export class Projection {
public visibleRegion: VisibleRegion;
public containsCoordinate(position: Position): Boolean;
public fromScreenLocation(point: Point): Position;
public toScreenLocation(position: Position): Point;
public ios: any; /* GMSProjection */
Expand Down
4 changes: 4 additions & 0 deletions src/map-view.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,10 @@ export class Projection extends ProjectionBase {
return new VisibleRegion(this.ios.visibleRegion());
}

containsCoordinate(position: Position): Boolean {
return this.ios.containsCoordinate(position.ios);
}

fromScreenLocation(point: Point) {
var location = this.ios.coordinateForPoint(CGPointMake(point.x, point.y));
return new Position(location);
Expand Down

0 comments on commit cf5b0a7

Please sign in to comment.