@@ -167,14 +167,12 @@ export class MapService {
167
167
}
168
168
169
169
updateStyle ( style : MapboxGl . Style ) {
170
- // TODO Probably not so simple, write demo/tests
171
170
return this . zone . runOutsideAngular ( ( ) => {
172
171
this . mapInstance . setStyle ( style ) ;
173
172
} ) ;
174
173
}
175
174
176
175
updateMaxBounds ( maxBounds : MapboxGl . LngLatBoundsLike ) {
177
- // TODO Probably not so simple, write demo/tests
178
176
return this . zone . runOutsideAngular ( ( ) => {
179
177
this . mapInstance . setMaxBounds ( maxBounds ) ;
180
178
} ) ;
@@ -186,7 +184,7 @@ export class MapService {
186
184
}
187
185
188
186
queryRenderedFeatures (
189
- pointOrBox ?: MapboxGl . PointLike | MapboxGl . PointLike [ ] ,
187
+ pointOrBox ?: MapboxGl . PointLike | [ MapboxGl . PointLike , MapboxGl . PointLike ] ,
190
188
parameters ?: { layers ?: string [ ] , filter ?: any [ ] }
191
189
) : GeoJSON . Feature < GeoJSON . GeometryObject > [ ] {
192
190
return this . mapInstance . queryRenderedFeatures ( pointOrBox , parameters ) ;
@@ -289,10 +287,10 @@ export class MapService {
289
287
this . zone . run ( ( ) => marker . markersEvents . dragEnd . emit ( event . target ) )
290
288
) ;
291
289
}
292
- markerInstance . setLngLat ( marker . markersOptions . feature ?
293
- marker . markersOptions . feature . geometry ! . coordinates :
294
- marker . markersOptions . lngLat !
295
- ) ;
290
+ const lngLat : MapboxGl . LngLatLike = marker . markersOptions . feature ?
291
+ < [ number , number ] > marker . markersOptions . feature . geometry ! . coordinates :
292
+ marker . markersOptions . lngLat ! ;
293
+ markerInstance . setLngLat ( lngLat ) ;
296
294
return this . zone . runOutsideAngular ( ( ) => {
297
295
markerInstance . addTo ( this . mapInstance ) ;
298
296
return markerInstance ;
@@ -465,12 +463,22 @@ export class MapService {
465
463
} ) ;
466
464
}
467
465
468
- fitBounds ( bounds : MapboxGl . LngLatBoundsLike , options ?: any ) {
466
+ fitBounds ( bounds : MapboxGl . LngLatBoundsLike , options ?: MapboxGl . FitBoundsOptions ) {
469
467
return this . zone . runOutsideAngular ( ( ) => {
470
468
this . mapInstance . fitBounds ( bounds , options ) ;
471
469
} ) ;
472
470
}
473
471
472
+ fitScreenCoordinates (
473
+ points : [ MapboxGl . PointLike , MapboxGl . PointLike ] ,
474
+ bearing : number ,
475
+ options ?: MapboxGl . AnimationOptions & MapboxGl . CameraOptions
476
+ ) {
477
+ return this . zone . runOutsideAngular ( ( ) => {
478
+ this . mapInstance . fitScreenCoordinates ( points [ 0 ] , points [ 1 ] , bearing , options ) ;
479
+ } ) ;
480
+ }
481
+
474
482
getCurrentViewportBbox ( ) : BBox {
475
483
const canvas = this . mapInstance . getCanvas ( ) ;
476
484
const w = parseInt ( canvas . style . width ! , 10 ) ;
@@ -515,10 +523,6 @@ export class MapService {
515
523
516
524
private removeLayers ( ) {
517
525
for ( const layerId of this . layerIdsToRemove ) {
518
- this . mapInstance . off ( 'click' , layerId ) ;
519
- this . mapInstance . off ( 'mouseenter' , layerId ) ;
520
- this . mapInstance . off ( 'mouseleave' , layerId ) ;
521
- this . mapInstance . off ( 'mousemove' , layerId ) ;
522
526
this . mapInstance . removeLayer ( layerId ) ;
523
527
}
524
528
this . layerIdsToRemove = [ ] ;
0 commit comments