Skip to content

Commit

Permalink
Fix compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Wykks committed Jul 27, 2022
1 parent 1fa3c51 commit a8d1460
Show file tree
Hide file tree
Showing 43 changed files with 293 additions and 290 deletions.
2 changes: 1 addition & 1 deletion apps/showcase/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
"maximumError": "2mb"
},
{
"type": "anyComponentStyle",
Expand Down
8 changes: 5 additions & 3 deletions apps/showcase/src/app/demo/demo-index.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ <h3 matSubheader>{{ cat }}</h3>
mat-list-item
[routerLink]="'/demo/' + (isEditMode ? '/edit/' : '') + route.path"
routerLinkActive="active"
[routerLinkActiveOptions]="{
_routerLinkActiveWakeUpHack_: isEditMode
}"
[routerLinkActiveOptions]="
$any({
_routerLinkActiveWakeUpHack_: isEditMode
})
"
#exampleLink
>
{{ route.data.label }}
Expand Down
2 changes: 1 addition & 1 deletion apps/showcase/src/app/demo/demo-index.component.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use '~@angular/material' as mat;
@use '@angular/material' as mat;

:host,
.content {
Expand Down
13 changes: 7 additions & 6 deletions apps/showcase/src/app/demo/demo-index.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class DemoIndexComponent implements OnInit, AfterViewInit {
categories: Category[];
searchTerm: string;
sidenavIsOpen = true;
isEditMode = !!this.activatedRoute.snapshot.firstChild!.params.demoUrl;
isEditMode = !!this.activatedRoute.snapshot.firstChild?.params['demoUrl'];

@ViewChildren('exampleLink', { read: ElementRef })
exampleLinks: QueryList<ElementRef>;
Expand All @@ -39,8 +39,8 @@ export class DemoIndexComponent implements OnInit, AfterViewInit {
private mapResizeService: MapResizeService
) {
this.originalRoutes = groupBy(DEMO_ROUTES[0].children, (route) =>
route.data ? route.data.cat : null
) as any as RoutesByCategory;
route.data ? route.data['cat'] : null
) as unknown as RoutesByCategory;
this.categories = [
Category.STYLES,
Category.LAYERS,
Expand All @@ -64,16 +64,17 @@ export class DemoIndexComponent implements OnInit, AfterViewInit {
}

toggleEdit(change: MatSlideToggleChange) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const snapshot = this.activatedRoute.snapshot.firstChild!;
if (change.checked) {
this.router.navigate(['demo', 'edit', snapshot.url[0].path]);
} else {
this.router.navigate(['demo', snapshot.params.demoUrl]);
this.router.navigate(['demo', snapshot.params['demoUrl']]);
}
}

onSidenavChange() {
this.mapResizeService.resize$.next();
this.mapResizeService.resize$.next(undefined);
}

search() {
Expand All @@ -83,7 +84,7 @@ export class DemoIndexComponent implements OnInit, AfterViewInit {
category.forEach((route, index) => {
if (
route.data &&
!(route.data.label as string)
!(route.data['label'] as string)
.toLowerCase()
.includes(this.searchTerm.toLowerCase())
) {
Expand Down
4 changes: 0 additions & 4 deletions apps/showcase/src/app/demo/demo.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { MatSidenavModule } from '@angular/material/sidenav';
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
import { RouterModule } from '@angular/router';
import { NgxMapboxGLModule } from 'ngx-mapbox-gl';
import { NgxMapboxGlGeocoderControlModule } from 'ngx-mapbox-gl-geocoder-control';

import { LayoutModule } from '../shared/layout/layout.module';
import { DemoIndexComponent } from './demo-index.component';
Expand Down Expand Up @@ -45,7 +44,6 @@ import { LanguageSwitchComponent } from './examples/language-switch.component';
import { LiveUpdateFeatureComponent } from './examples/live-update-feature.component';
import { LiveUpdateImageSourceComponent } from './examples/live-update-image-srource.component';
import { LocateUserComponent } from './examples/locate-user.component';
import { MapboxGlGeocoderComponent } from './examples/mapbox-gl-geocoder.component';
import { MarkerAlignmentComponent } from './examples/marker-alignment.component';
import { NavigationComponent } from './examples/navigation.component';
import {
Expand Down Expand Up @@ -77,7 +75,6 @@ import { StackblitzEditComponent } from './stackblitz-edit/stackblitz-edit.compo
FormsModule,

NgxMapboxGLModule,
NgxMapboxGlGeocoderControlModule,

LayoutModule,

Expand Down Expand Up @@ -118,7 +115,6 @@ import { StackblitzEditComponent } from './stackblitz-edit/stackblitz-edit.compo
FullscreenComponent,
NavigationComponent,
LocateUserComponent,
MapboxGlGeocoderComponent,
AttributionPositionComponent,
NgxScaleControlComponent,
NgxCustomControlComponent,
Expand Down
24 changes: 15 additions & 9 deletions apps/showcase/src/app/demo/examples/3d-buildings.component.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Component } from '@angular/core';
import { Map, SymbolLayer } from 'mapbox-gl';
import { AnyLayer, Map } from 'mapbox-gl';

@Component({
selector: 'showcase-demo',
template: `
<mgl-map
[style]="'mapbox://styles/mapbox/light-v9'"
[zoom]="15.5"
[zoom]="[15.5]"
[center]="[-74.0066, 40.7135]"
[pitch]="45"
[bearing]="-17.6"
[pitch]="[45]"
[bearing]="[-17.6]"
(mapLoad)="onLoad($event)"
>
<mgl-layer
Expand Down Expand Up @@ -48,16 +48,22 @@ import { Map, SymbolLayer } from 'mapbox-gl';
styleUrls: ['./examples.css'],
})
export class Display3dBuildingsComponent {
labelLayerId: string;
labelLayerId?: string;

onLoad(mapInstance: Map) {
const layers = mapInstance.getStyle().layers!;
const layers = mapInstance.getStyle().layers;
if (!layers) {
return;
}
this.labelLayerId = this.getLabelLayerId(layers);
}

private getLabelLayerId(layers: AnyLayer[]) {
for (const layer of layers) {
if (layer.type === 'symbol' && layer.layout!['text-field']) {
this.labelLayerId = layer.id;
break;
if (layer.type === 'symbol' && layer.layout?.['text-field']) {
return layer.id;
}
}
return;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { Component, OnInit } from '@angular/core';
features: [
{
type: 'Feature',
properties: {},
geometry: {
type: 'Point',
coordinates: [0, 0]
Expand Down
1 change: 1 addition & 0 deletions apps/showcase/src/app/demo/examples/add-image.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { Component } from '@angular/core';
features: [
{
type: 'Feature',
properties: {},
geometry: {
type: 'Point',
coordinates: [0, 0]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component } from '@angular/core';
import { MapMouseEvent, Map } from 'mapbox-gl';
import { Map, MapMouseEvent } from 'mapbox-gl';

@Component({
selector: 'showcase-demo',
Expand Down Expand Up @@ -37,19 +37,19 @@ export class CenterOnSymbolComponent {
map: Map;
cursorStyle: string;

center = [-90.96, -0.47];
center: [number, number] = [-90.96, -0.47];

geometries = [
{
type: 'Point',
type: 'Point' as const,
coordinates: [-91.395263671875, -0.9145729757782163],
},
{
type: 'Point',
type: 'Point' as const,
coordinates: [-90.32958984375, -0.6344474832838974],
},
{
type: 'Point',
type: 'Point' as const,
coordinates: [-91.34033203125, 0.01647949196029245],
},
];
Expand Down
6 changes: 4 additions & 2 deletions apps/showcase/src/app/demo/examples/cluster.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./examples.css'],
})
export class ClusterComponent implements OnInit {
earthquakes: object;
earthquakes: GeoJSON.FeatureCollection<GeoJSON.Geometry>;

async ngOnInit() {
this.earthquakes = await import('./earthquakes.geo.json');
this.earthquakes = (await import(
'./earthquakes.geo.json'
)) as unknown as GeoJSON.FeatureCollection<GeoJSON.Geometry>;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,38 +28,38 @@ import { Component } from '@angular/core';
})
export class CustomMarkerIconsComponent {
geojson = {
type: 'FeatureCollection',
type: 'FeatureCollection' as const,
features: [
{
type: 'Feature',
type: 'Feature' as const,
properties: {
message: 'Foo',
iconSize: [60, 60],
},
geometry: {
type: 'Point',
type: 'Point' as const,
coordinates: [-66.324462890625, -16.024695711685304],
},
},
{
type: 'Feature',
type: 'Feature' as const,
properties: {
message: 'Bar',
iconSize: [50, 50],
},
geometry: {
type: 'Point',
type: 'Point' as const,
coordinates: [-61.2158203125, -15.97189158092897],
},
},
{
type: 'Feature',
type: 'Feature' as const,
properties: {
message: 'Baz',
iconSize: [40, 40],
},
geometry: {
type: 'Point',
type: 'Point' as const,
coordinates: [-63.29223632812499, -18.28151823530889],
},
},
Expand Down
8 changes: 5 additions & 3 deletions apps/showcase/src/app/demo/examples/heatmap.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { Layer } from 'mapbox-gl';
<mgl-layer
*ngFor="let layer of clusterLayers"
[id]="layer.id"
[type]="layer.type"
[type]="$any(layer.type)"
source="earthquakes"
[filter]="layer.filter"
[paint]="layer.paint"
Expand All @@ -44,11 +44,13 @@ import { Layer } from 'mapbox-gl';
styleUrls: ['./examples.css'],
})
export class HeatMapComponent implements OnInit {
earthquakes: object;
earthquakes: GeoJSON.FeatureCollection<GeoJSON.Geometry>;
clusterLayers: Layer[];

async ngOnInit() {
this.earthquakes = await import('./earthquakes.geo.json');
this.earthquakes = (await import(
'./earthquakes.geo.json'
)) as unknown as GeoJSON.FeatureCollection<GeoJSON.Geometry>;
const layersData: [number, string][] = [
[0, 'green'],
[20, 'orange'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { LngLatLike } from 'mapbox-gl';
[zoom]="zoom"
[center]="center"
[centerWithPanTo]="true"
[pitch]="pitch"
[pitch]="[pitch]"
movingMethod="jumpTo"
>
<mgl-geojson-source *ngIf="data" id="trace" [data]="data">
Expand All @@ -33,19 +33,17 @@ import { LngLatLike } from 'mapbox-gl';
export class LiveUpdateFeatureComponent implements OnInit, OnDestroy {
data: GeoJSON.FeatureCollection<GeoJSON.LineString>;
center: LngLatLike;
zoom = [0];
zoom: [number] = [0];
pitch: number;

private timer: number;

constructor() {}

async ngOnInit() {
const data: GeoJSON.FeatureCollection<GeoJSON.LineString> = (await import(
'./hike.geo.json'
)) as any;
const coordinates = data.features[0].geometry!.coordinates;
data.features[0].geometry!.coordinates = [coordinates[0]];
const coordinates = data.features[0].geometry.coordinates;
data.features[0].geometry.coordinates = [coordinates[0]];
this.data = data;
this.center = coordinates[0] as [number, number];
this.zoom = [14];
Expand All @@ -54,7 +52,7 @@ export class LiveUpdateFeatureComponent implements OnInit, OnDestroy {
this.timer = window.setInterval(() => {
if (i < coordinates.length) {
this.center = coordinates[i] as [number, number];
data.features[0].geometry!.coordinates.push(coordinates[i]);
data.features[0].geometry.coordinates.push(coordinates[i]);
this.data = { ...this.data };
i++;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { interval, Subscription } from 'rxjs';
export class LiveUpdateImageSourceComponent implements OnInit, OnDestroy {
private sub: Subscription;
private readonly size = 0.001;
center: number[];
center: [number, number];

url = 'assets/red.png';
coordinates: number[][];
Expand All @@ -40,10 +40,10 @@ export class LiveUpdateImageSourceComponent implements OnInit, OnDestroy {
const data: GeoJSON.FeatureCollection<GeoJSON.LineString> = (await import(
'./hike.geo.json'
)) as any;
const points = data.features[0].geometry!.coordinates;
const points = data.features[0].geometry?.coordinates;
const coordinates = points.map((c) => this.makeRectangle(c));

this.center = points[0];
this.center = points[0] as [number, number];
this.coordinates = coordinates[0];

let i = 0;
Expand Down

This file was deleted.

Loading

0 comments on commit a8d1460

Please sign in to comment.