-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathzoom-range-modifier-service.ts
More file actions
42 lines (36 loc) · 1.09 KB
/
zoom-range-modifier-service.ts
File metadata and controls
42 lines (36 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { Injectable } from "@angular/core";
@Injectable()
export class ZoomRangeModifierService
{
private originalSetFunc: Function;
private zoomRangeModifier: any;
public constructor()
{
}
public enableSuperZoom(map: google.maps.Map, superZoomMax: number): void
{
// disable superzoom on any previous map
this.disableSuperZoom();
// allow max zoom beyond what Google says maxZoom is
// http://stackoverflow.com/a/30315215/2118030
this.zoomRangeModifier = Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(map)));
this.originalSetFunc = this.zoomRangeModifier.set;
let originalSetFunc: any = this.zoomRangeModifier.set;
let hijackedSetFunc: any = function(a: any, b: any): void {
if (a === "zoomRange") {
b.max = superZoomMax;
}
/* tslint:disable:no-invalid-this */
originalSetFunc.call(this, a, b);
/* tslint:enable:no-invalid-this */
};
this.zoomRangeModifier.set = hijackedSetFunc;
}
public disableSuperZoom(): void
{
if (!!this.zoomRangeModifier && !!this.originalSetFunc)
{
this.zoomRangeModifier.set = this.originalSetFunc;
}
}
}