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(SebmGoogleMap): support scrollwheel mapOption #232

Closed
wants to merge 1 commit into from
Closed
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
28 changes: 18 additions & 10 deletions src/directives/google-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ import {MouseEvent} from '../events';
@Component({
selector: 'sebm-google-map',
providers: [GoogleMapsAPIWrapper, MarkerManager],
inputs: ['longitude', 'latitude', 'zoom', 'disableDoubleClickZoom', 'disableDefaultUI'],
inputs: [
'longitude', 'latitude', 'zoom', 'disableDoubleClickZoom', 'disableDefaultUI', 'scrollwheel'
],
outputs: ['mapClick', 'mapRightClick', 'mapDblClick', 'centerChange'],
host: {'[class.sebm-google-map-container]': 'true'},
styles: [`
Expand Down Expand Up @@ -62,10 +64,15 @@ export class SebmGoogleMap implements OnChanges,
*/
disableDefaultUI: boolean = false;

/**
* If false, disables scrollwheel zooming on the map. The scrollwheel is enabled by default.
*/
scrollwheel: boolean = true;

/**
* Map option attributes that can change over time
*/
private static _mapOptionsAttributes: string[] = ['disableDoubleClickZoom'];
private static _mapOptionsAttributes: string[] = ['disableDoubleClickZoom', 'scrollwheel'];

/**
* This event emitter gets emitted when the user clicks on the map (but not when they click on a
Expand Down Expand Up @@ -109,16 +116,17 @@ export class SebmGoogleMap implements OnChanges,
this._handleMapMouseEvents();
}

private static _containsMapOptionsChange(changesKeys: string[]): boolean {
return changesKeys.every(
(key: string) => { return SebmGoogleMap._mapOptionsAttributes.indexOf(key) !== 1; });
/* @internal */
ngOnChanges(changes: {[propName: string]: SimpleChange}) {
this._updateMapOptionsChanges(changes);
}

/** @internal */
ngOnChanges(changes: {[propName: string]: SimpleChange}) {
if (SebmGoogleMap._containsMapOptionsChange(Object.keys(changes))) {
this._mapsWrapper.setMapOptions({disableDoubleClickZoom: this.disableDoubleClickZoom});
}
private _updateMapOptionsChanges(changes: {[propName: string]: SimpleChange}) {
let options: {[propName: string]: any} = {};
let optionKeys =
Object.keys(changes).filter(k => SebmGoogleMap._mapOptionsAttributes.indexOf(k) !== -1);
optionKeys.forEach((k) => { options[k] = changes[k].currentValue; });
this._mapsWrapper.setMapOptions(options);
}

/**
Expand Down