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

feat(AgmMap): add area restriction option #1624

Merged
2 commits merged into from
May 31, 2019
Merged
Show file tree
Hide file tree
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
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;
}