Skip to content

Commit

Permalink
feat: update mapbox-gl to 0.52.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Wykks committed Jan 27, 2019
1 parent a71a79c commit 39a0f30
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ Include the following components:
## How to start

```
npm install ngx-mapbox-gl mapbox-gl@0.51.0 --save
npm install ngx-mapbox-gl mapbox-gl@0.52.0 --save
```
If using typescript add mapbox-gl types
```
npm install @types/mapbox-gl@0.51.0 --save-dev
npm install @types/mapbox-gl@0.52.0 --save-dev
```

Load the css of mapbox-gl (and mapbox-gl-geocoder if mglGeocoder is used)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@turf/random": "^6.0.2",
"hammerjs": "^2.0.8",
"lodash-es": "^4.17.11",
"mapbox-gl": "0.51.0",
"mapbox-gl": "0.52.0",
"ngx-md": "^7.0.0",
"rxjs": "^6.3.3",
"scroll-into-view-if-needed": "^2.2.20",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Directive, OnInit, Host } from '@angular/core';
import { Directive, OnInit, Host, Input } from '@angular/core';
import { FullscreenControl } from 'mapbox-gl';
import { MapService } from '../map/map.service';
import { ControlComponent } from './control.component';
Expand All @@ -7,6 +7,8 @@ import { ControlComponent } from './control.component';
selector: '[mglFullscreen]'
})
export class FullscreenControlDirective implements OnInit {
/* Init inputs */
@Input() container?: HTMLElement;

constructor(
private MapService: MapService,
Expand All @@ -18,7 +20,12 @@ export class FullscreenControlDirective implements OnInit {
if (this.ControlComponent.control) {
throw new Error('Another control is already set for this control');
}
this.ControlComponent.control = new FullscreenControl();
const options: { container?: HTMLElement } = {};
if (this.container !== undefined) {
options.container = this.container;
}
// @ts-ignore
this.ControlComponent.control = new FullscreenControl(options); // @types/mapbox-gl update needed
this.MapService.addControl(this.ControlComponent.control, this.ControlComponent.position);
});
}
Expand Down
1 change: 1 addition & 0 deletions projects/ngx-mapbox-gl/src/lib/map/map.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export class MapComponent implements OnChanges, OnDestroy, AfterViewInit, MapEve
@Output() webGlContextLost = new EventEmitter<void>();
@Output() webGlContextRestored = new EventEmitter<void>();
@Output() load = new EventEmitter<any>();
@Output() idle = new EventEmitter<void>();
@Output() render = new EventEmitter<void>();
@Output() error = new EventEmitter<any>(); // TODO Check type
@Output() data = new EventEmitter<EventData>();
Expand Down
3 changes: 2 additions & 1 deletion projects/ngx-mapbox-gl/src/lib/map/map.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ describe('MapService', () => {
sourceData: new EventEmitter<EventData>(),
dataLoading: new EventEmitter<EventData>(),
styleDataLoading: new EventEmitter<EventData>(),
sourceDataLoading: new EventEmitter<EventData>()
sourceDataLoading: new EventEmitter<EventData>(),
idle: new EventEmitter<void>()
};
});

Expand Down
3 changes: 3 additions & 0 deletions projects/ngx-mapbox-gl/src/lib/map/map.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,9 @@ export class MapService {
if (events.sourceDataLoading.observers.length) {
this.mapInstance.on('sourcedataloading', (evt: MapboxGl.EventData) => this.zone.run(() => events.sourceDataLoading.emit(evt)));
}
if (events.idle.observers.length) {
this.mapInstance.on('idle', () => this.zone.run(() => events.idle.emit()));
}
}

// TODO move this elsewhere
Expand Down
1 change: 1 addition & 0 deletions projects/ngx-mapbox-gl/src/lib/map/map.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export interface MapEvent {
dataLoading: EventEmitter<EventData>;
styleDataLoading: EventEmitter<EventData>;
sourceDataLoading: EventEmitter<EventData>;
idle: EventEmitter<void>;
}

export interface GeocoderEvent {
Expand Down

0 comments on commit 39a0f30

Please sign in to comment.