Skip to content

Commit

Permalink
fix(layer): use new interface MapLayerMouseEvent
Browse files Browse the repository at this point in the history
fix #89
  • Loading branch information
Wykks committed Jan 27, 2019
1 parent b06e848 commit 1a5f369
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
12 changes: 6 additions & 6 deletions projects/ngx-mapbox-gl/src/lib/layer/layer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ import {
Layer,
LineLayout,
LinePaint,
MapMouseEvent,
RasterLayout,
RasterPaint,
RasterSource,
SymbolLayout,
SymbolPaint,
VectorSource,
VideoSource
VideoSource,
MapLayerMouseEvent
} from 'mapbox-gl';
import { fromEvent, Subscription } from 'rxjs';
import { filter, mapTo, switchMap, startWith } from 'rxjs/operators';
Expand All @@ -56,10 +56,10 @@ export class LayerComponent implements OnInit, OnDestroy, OnChanges, Layer {
@Input() minzoom?: number;
@Input() maxzoom?: number;

@Output() click = new EventEmitter<MapMouseEvent>();
@Output() mouseEnter = new EventEmitter<MapMouseEvent>();
@Output() mouseLeave = new EventEmitter<MapMouseEvent>();
@Output() mouseMove = new EventEmitter<MapMouseEvent>();
@Output() click = new EventEmitter<MapLayerMouseEvent>();
@Output() mouseEnter = new EventEmitter<MapLayerMouseEvent>();
@Output() mouseLeave = new EventEmitter<MapLayerMouseEvent>();
@Output() mouseMove = new EventEmitter<MapLayerMouseEvent>();

private layerAdded = false;
private sub: Subscription;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component } from '@angular/core';
import { MapMouseEvent, LngLat } from 'mapbox-gl';
import { LngLat, MapLayerMouseEvent } from 'mapbox-gl';
import { GeoJsonProperties } from 'geojson';

@Component({
selector: 'showcase-demo',
Expand Down Expand Up @@ -36,12 +37,12 @@ import { MapMouseEvent, LngLat } from 'mapbox-gl';
styleUrls: ['./examples.css']
})
export class PolygonPopupOnClickComponent {
selectedElement: object;
selectedElement: GeoJsonProperties;
selectedLngLat: LngLat;
cursorStyle: string;

onClick(evt: MapMouseEvent) {
onClick(evt: MapLayerMouseEvent) {
this.selectedLngLat = evt.lngLat;
this.selectedElement = (<any>evt).features[0].properties;
this.selectedElement = evt.features![0].properties;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component } from '@angular/core';
import { MapMouseEvent } from 'mapbox-gl';
import { MapboxGeoJSONFeature, MapLayerMouseEvent } from 'mapbox-gl';

@Component({
selector: 'showcase-demo',
Expand Down Expand Up @@ -38,7 +38,7 @@ import { MapMouseEvent } from 'mapbox-gl';
})
export class PopupOnClickComponent {
points: GeoJSON.FeatureCollection<GeoJSON.Point>;
selectedPoint: GeoJSON.Feature<GeoJSON.Point> | null;
selectedPoint: MapboxGeoJSONFeature | null;
cursorStyle: string;

constructor() {
Expand Down Expand Up @@ -147,7 +147,7 @@ export class PopupOnClickComponent {
};
}

onClick(evt: MapMouseEvent) {
this.selectedPoint = (<any>evt).features[0];
onClick(evt: MapLayerMouseEvent) {
this.selectedPoint = evt.features![0];
}
}

0 comments on commit 1a5f369

Please sign in to comment.