From 0789a176454f123c00fe3491284e1da6ceb2bcc0 Mon Sep 17 00:00:00 2001 From: lazarljubenovic Date: Thu, 24 Nov 2016 20:19:17 +0100 Subject: [PATCH] feat(SebmGoogleMap): support maxZoom and minZoom --- src/core/directives/google-map.ts | 25 ++++++++++++++++++++----- src/core/services/google-maps-types.ts | 2 ++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/core/directives/google-map.ts b/src/core/directives/google-map.ts index 981fb53ac..a0101fb1d 100644 --- a/src/core/directives/google-map.ts +++ b/src/core/directives/google-map.ts @@ -45,10 +45,10 @@ import {KmlLayerManager} from './../services/managers/kml-layer-manager'; PolygonManager, KmlLayerManager ], inputs: [ - 'longitude', 'latitude', 'zoom', 'draggable: mapDraggable', 'disableDoubleClickZoom', - 'disableDefaultUI', 'scrollwheel', 'backgroundColor', 'draggableCursor', 'draggingCursor', - 'keyboardShortcuts', 'zoomControl', 'styles', 'usePanning', 'streetViewControl', 'fitBounds', - 'scaleControl', 'mapTypeControl' + 'longitude', 'latitude', 'zoom', 'minZoom', 'maxZoom', 'draggable: mapDraggable', + 'disableDoubleClickZoom', 'disableDefaultUI', 'scrollwheel', 'backgroundColor', 'draggableCursor', + 'draggingCursor', 'keyboardShortcuts', 'zoomControl', 'styles', 'usePanning', 'streetViewControl', + 'fitBounds', 'scaleControl', 'mapTypeControl' ], outputs: [ 'mapClick', 'mapRightClick', 'mapDblClick', 'centerChange', 'idle', 'boundsChange', 'zoomChange' @@ -86,6 +86,18 @@ export class SebmGoogleMap implements OnChanges, OnInit, OnDestroy { */ zoom: number = 8; + /** + * The minimal zoom level of the map allowed. When not provided, no restrictions to the zoom level + * are enforced. + */ + minZoom: number; + + /** + * The maximal zoom level of the map allowed. When not provided, no restrictions to the zoom level + * are enforced. + */ + maxZoom: number; + /** * Enables/disables if map is draggable. */ @@ -180,7 +192,8 @@ export class SebmGoogleMap implements OnChanges, OnInit, OnDestroy { */ private static _mapOptionsAttributes: string[] = [ 'disableDoubleClickZoom', 'scrollwheel', 'draggable', 'draggableCursor', 'draggingCursor', - 'keyboardShortcuts', 'zoomControl', 'styles', 'streetViewControl', 'zoom', 'mapTypeControl' + 'keyboardShortcuts', 'zoomControl', 'styles', 'streetViewControl', 'zoom', 'mapTypeControl', + 'minZoom', 'maxZoom' ]; private _observableSubscriptions: Subscription[] = []; @@ -236,6 +249,8 @@ export class SebmGoogleMap implements OnChanges, OnInit, OnDestroy { this._mapsWrapper.createMap(el, { center: {lat: this.latitude || 0, lng: this.longitude || 0}, zoom: this.zoom, + minZoom: this.minZoom, + maxZoom: this.maxZoom, disableDefaultUI: this.disableDefaultUI, backgroundColor: this.backgroundColor, draggable: this.draggable, diff --git a/src/core/services/google-maps-types.ts b/src/core/services/google-maps-types.ts index a90537679..0fe6dc936 100644 --- a/src/core/services/google-maps-types.ts +++ b/src/core/services/google-maps-types.ts @@ -120,6 +120,8 @@ export interface MouseEvent { latLng: LatLng; } export interface MapOptions { center?: LatLng|LatLngLiteral; zoom?: number; + minZoom?: number; + maxZoom?: number; disableDoubleClickZoom?: boolean; disableDefaultUI?: boolean; backgroundColor?: string;