-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(map-legend): add dynamic legend generation based on map context
- Loading branch information
1 parent
48c95d3
commit 17d0a56
Showing
8 changed files
with
123 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
libs/ui/map/src/lib/components/map-legend/map-legend.component.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.geosdk--legend-container { | ||
overflow: auto; | ||
} |
1 change: 1 addition & 0 deletions
1
libs/ui/map/src/lib/components/map-legend/map-legend.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div *ngIf="legendHTML" [innerHTML]="legendHTML.outerHTML"></div> |
21 changes: 21 additions & 0 deletions
21
libs/ui/map/src/lib/components/map-legend/map-legend.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing' | ||
|
||
import { MapLegendComponent } from './map-legend.component' | ||
|
||
describe('MapLegendComponent', () => { | ||
let component: MapLegendComponent | ||
let fixture: ComponentFixture<MapLegendComponent> | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [MapLegendComponent], | ||
}) | ||
fixture = TestBed.createComponent(MapLegendComponent) | ||
component = fixture.componentInstance | ||
fixture.detectChanges() | ||
}) | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy() | ||
}) | ||
}) |
36 changes: 36 additions & 0 deletions
36
libs/ui/map/src/lib/components/map-legend/map-legend.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { | ||
Component, | ||
EventEmitter, | ||
Input, | ||
OnChanges, | ||
Output, | ||
SimpleChanges, | ||
ViewEncapsulation, | ||
} from '@angular/core' | ||
import { MapContext } from '@geospatial-sdk/core' | ||
import { createLegendFromLayer } from '@geospatial-sdk/legend' | ||
import { NgIf } from '@angular/common' | ||
|
||
@Component({ | ||
selector: 'gn-ui-map-legend', | ||
templateUrl: './map-legend.component.html', | ||
standalone: true, | ||
styleUrls: ['./map-legend.component.css'], | ||
encapsulation: ViewEncapsulation.None, | ||
imports: [NgIf], | ||
}) | ||
export class MapLegendComponent implements OnChanges { | ||
@Input() context: MapContext | null | ||
@Output() legendStatusChange = new EventEmitter<boolean>() | ||
legendHTML: HTMLElement | false | ||
|
||
async ngOnChanges(changes: SimpleChanges) { | ||
if ('context' in changes && !changes['context'].isFirstChange()) { | ||
const mapContectLayer = changes['context'].currentValue.layers[0] | ||
console.log(mapContectLayer) | ||
this.legendHTML = await createLegendFromLayer(mapContectLayer) | ||
console.log(this.legendHTML) | ||
this.legendStatusChange.emit(!!this.legendHTML) | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters