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 option #211

Closed
wants to merge 1 commit into from
Closed
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
13 changes: 11 additions & 2 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'],
host: {'[class.sebm-google-map-container]': 'true'},
styles: [`
Expand All @@ -51,6 +53,7 @@ export class SebmGoogleMap implements OnChanges,
private _longitude: number = 0;
private _latitude: number = 0;
private _zoom: number = 8;
private _scrollwheel: boolean = true;
/**
* Enables/disables zoom and center on double click. Enabled by default.
*/
Expand Down Expand Up @@ -97,7 +100,8 @@ export class SebmGoogleMap implements OnChanges,
this._mapsWrapper.createMap(el, {
center: {lat: this._latitude, lng: this._longitude},
zoom: this._zoom,
disableDefaultUI: this.disableDefaultUI
disableDefaultUI: this.disableDefaultUI,
scrollwheel: this._scrollwheel
});
this._handleMapCenterChange();
this._handleMapZoomChange();
Expand Down Expand Up @@ -140,6 +144,11 @@ export class SebmGoogleMap implements OnChanges,
}
}

/**
* Sets the scrollwheel enables/disables on map. The default value is true
*/
set scrollwheel(value: boolean) { this._mapsWrapper.scrollwheel(value); }

/**
* The longitude that sets the center of the map.
*/
Expand Down
4 changes: 4 additions & 0 deletions src/services/google-maps-api-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ export class GoogleMapsAPIWrapper {
return this._map.then((map: mapTypes.GoogleMap) => map.setZoom(zoom));
}

scrollwheel(scrollwheel: boolean): Promise<void> {
return this._map.then((map: mapTypes.GoogleMap) => { map.scrollwheel = scrollwheel; });
}

getCenter(): Promise<mapTypes.LatLng> {
return this._map.then((map: mapTypes.GoogleMap) => map.getCenter());
}
Expand Down
2 changes: 2 additions & 0 deletions src/services/google-maps-types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export var google: any;

export interface GoogleMap {
scrollwheel?: boolean;
constructor(el: HTMLElement, opts?: MapOptions): void;
panTo(latLng: LatLng | LatLngLiteral): void;
setZoom(zoom: number): void;
Expand Down Expand Up @@ -56,4 +57,5 @@ export interface MapOptions {
zoom?: number;
disableDoubleClickZoom?: boolean;
disableDefaultUI?: boolean;
scrollwheel?: boolean;
}