Skip to content

Commit

Permalink
feat(AgmMap): add area restriction option
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilchlebek authored and doom777 committed May 31, 2019
1 parent 8b2f2dc commit 7201a75
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/core/directives/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import {Subscription} from 'rxjs';
import {MouseEvent} from '../map-types';
import {GoogleMapsAPIWrapper} from '../services/google-maps-api-wrapper';
import {
FullscreenControlOptions, LatLng, LatLngLiteral, MapTypeControlOptions, MapTypeId, PanControlOptions,
RotateControlOptions, ScaleControlOptions, StreetViewControlOptions, ZoomControlOptions} from '../services/google-maps-types';
FullscreenControlOptions, LatLng, LatLngLiteral, MapTypeControlOptions, MapTypeId, PanControlOptions, MapRestriction,
RotateControlOptions, ScaleControlOptions, StreetViewControlOptions, ZoomControlOptions
} from '../services/google-maps-types';
import {LatLngBounds, LatLngBoundsLiteral, MapTypeStyle} from '../services/google-maps-types';
import {CircleManager} from '../services/managers/circle-manager';
import {RectangleManager} from '../services/managers/rectangle-manager';
Expand Down Expand Up @@ -259,6 +260,11 @@ export class AgmMap implements OnChanges, OnInit, OnDestroy {
*/
@Input() gestureHandling: 'cooperative'|'greedy'|'none'|'auto' = 'auto';

/**
* Options for restricting the bounds of the map.
* User cannot pan or zoom away from restricted area.
*/
@Input() restriction: MapRestriction;
/**
* Map option attributes that can change over time
*/
Expand All @@ -268,7 +274,7 @@ export class AgmMap implements OnChanges, OnInit, OnDestroy {
'streetViewControlOptions', 'zoom', 'mapTypeControl', 'mapTypeControlOptions', 'minZoom',
'maxZoom', 'panControl', 'panControlOptions', 'rotateControl', 'rotateControlOptions',
'fullscreenControl', 'fullscreenControlOptions', 'scaleControl', 'scaleControlOptions',
'mapTypeId', 'clickableIcons', 'gestureHandling'
'mapTypeId', 'clickableIcons', 'gestureHandling', 'restriction'
];

private _observableSubscriptions: Subscription[] = [];
Expand Down Expand Up @@ -363,7 +369,8 @@ export class AgmMap implements OnChanges, OnInit, OnDestroy {
fullscreenControlOptions: this.fullscreenControlOptions,
mapTypeId: this.mapTypeId,
clickableIcons: this.clickableIcons,
gestureHandling: this.gestureHandling
gestureHandling: this.gestureHandling,
restriction: this.restriction,
})
.then(() => this._mapsWrapper.getNativeMap())
.then(map => this.mapReady.emit(map));
Expand Down
7 changes: 7 additions & 0 deletions packages/core/services/google-maps-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ export interface MapOptions {
mapTypeId?: string|MapTypeId;
clickableIcons?: boolean;
gestureHandling?: 'cooperative'|'greedy'|'none'|'auto';
restriction?: MapRestriction;
}

export interface MapTypeStyle {
Expand Down Expand Up @@ -596,3 +597,9 @@ export interface FullscreenControlOptions {
*/
position?: ControlPosition;
}

/** Options for the restricting the bounds of the map. */
export interface MapRestriction {
latLngBounds: LatLngBounds|LatLngBoundsLiteral;
strictBounds?: boolean;
}

0 comments on commit 7201a75

Please sign in to comment.