Skip to content

Commit

Permalink
refactor: fix for ts 2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Wykks committed Nov 15, 2017
1 parent 097a5ac commit 13ebc7f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
9 changes: 7 additions & 2 deletions src/app/lib/control/geolocate-control.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,14 @@ export class GeolocateControlDirective implements OnInit {
trackUserLocation: this.trackUserLocation,
showUserLocation: this.showUserLocation
};

Object.keys(options)
.forEach((key: keyof typeof options) =>
options[key] === undefined && delete options[key]);
.forEach((key: string) => {
const tkey = <keyof typeof options>key;
if (options[tkey] === undefined) {
delete options[tkey];
}
});
this.ControlComponent.control = new GeolocateControl(options);
this.MapService.addControl(this.ControlComponent.control, this.ControlComponent.position);
});
Expand Down
16 changes: 12 additions & 4 deletions src/app/lib/map/map.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,12 @@ export class MapService {
addLayer(layer: SetupLayer, before?: string) {
this.zone.runOutsideAngular(() => {
Object.keys(layer.layerOptions)
.forEach((key: keyof MapboxGl.Layer) =>
layer.layerOptions[key] === undefined && delete layer.layerOptions[key]);
.forEach((key: string) => {
const tkey = <keyof MapboxGl.Layer>key;
if (layer.layerOptions[tkey] === undefined) {
delete layer.layerOptions[tkey];
}
});
this.mapInstance.addLayer(layer.layerOptions, before);
this.mapInstance.on('click', layer.layerOptions.id, (evt: MapboxGl.MapMouseEvent) => {
this.zone.run(() => {
Expand Down Expand Up @@ -340,8 +344,12 @@ export class MapService {

private createMap(options: MapboxGl.MapboxOptions) {
Object.keys(options)
.forEach((key: keyof MapboxGl.MapboxOptions) =>
options[key] === undefined && delete options[key]);
.forEach((key: string) => {
const tkey = <keyof MapboxGl.MapboxOptions>key;
if (options[tkey] === undefined) {
delete options[tkey];
}
});
this.mapInstance = new MapboxGl.Map(options);
}

Expand Down

0 comments on commit 13ebc7f

Please sign in to comment.