diff --git a/src/app/color-select-hover/color-select-hover.component.ts b/src/app/color-select-hover/color-select-hover.component.ts index a8497d99..25c6b7de 100644 --- a/src/app/color-select-hover/color-select-hover.component.ts +++ b/src/app/color-select-hover/color-select-hover.component.ts @@ -1,16 +1,17 @@ -import { Component, QueryList, ViewChild, ViewChildren } from '@angular/core'; -import { LayerVectorComponent, MapComponent } from 'ngx-openlayers'; -import { Feature } from 'ol'; -import { Layer } from 'ol/layer'; -import { Fill, Stroke, Style } from 'ol/style'; +import {Component, QueryList, ViewChild, ViewChildren} from '@angular/core'; +import {LayerVectorComponent, MapComponent} from 'ngx-openlayers'; +import {Fill, Stroke, Style} from 'ol/style'; +import {pointerMove} from 'ol/events/condition'; +import {SelectEvent} from 'ol/interaction/Select'; @Component({ selector: 'app-color-select-hover', template: ` - + - + + @@ -19,17 +20,11 @@ import { Fill, Stroke, Style } from 'ol/style'; - - - - + + + + - - - - - - @@ -46,10 +41,7 @@ import { Fill, Stroke, Style } from 'ol/style'; `, }) export class ColorSelectHoverComponent { - @ViewChild('map', { static: true }) - map: MapComponent; - @ViewChildren('aoiLayerVector') - aoiLayerVector: QueryList; + protected readonly pointerMove = pointerMove; features = { type: 'FeatureCollection', @@ -125,7 +117,7 @@ export class ColorSelectHoverComponent { ], }; - styleInteratiselected = new Style({ + styleInteractionClick = new Style({ fill: new Fill({ color: 'rgba(0, 153, 255, 0.1)', }), @@ -135,24 +127,21 @@ export class ColorSelectHoverComponent { }), }); - hoveredFeatureId; + styleInteractionHover = new Style({ + fill: new Fill({ + color: 'rgba(47,255,0,0.1)', + }), + stroke: new Stroke({ + color: 'rgb(238,255,0)', + width: 3, + }), + }); - changeFeatureHovered(event): void { - const hit: Feature = this.map.instance.forEachFeatureAtPixel(event.pixel, (f) => f, { - layerFilter: inLayer(...this.aoiLayerVector.toArray()), - hitTolerance: 10, - }) as Feature; + onHover(event: SelectEvent): void { + console.log(event); + } - if (!hit && this.hoveredFeatureId) { - this.hoveredFeatureId = null; - } - if (hit && hit.getId() !== this.hoveredFeatureId) { - this.hoveredFeatureId = hit.getId(); - } + onSelect(event: SelectEvent): void { + console.log(event); } } - -const inLayer = - (...layers: LayerVectorComponent[]): ((l: Layer) => boolean) => - (l: Layer) => - layers.some((layer) => layer.instance === l); diff --git a/src/app/cursor-position/cursor-position.component.ts b/src/app/cursor-position/cursor-position.component.ts index 1be438e0..e7954a7f 100644 --- a/src/app/cursor-position/cursor-position.component.ts +++ b/src/app/cursor-position/cursor-position.component.ts @@ -1,12 +1,13 @@ import { Component } from '@angular/core'; -import { transform } from 'ol/proj'; +import {createStringXY, toStringHDMS, toStringXY} from 'ol/coordinate'; @Component({ selector: 'app-cursor-position', template: ` - + + @@ -15,56 +16,20 @@ import { transform } from 'ol/proj'; -
-
-

Cursor coordinates

- Longitude: {{ lonToString(lon) }} Latitude: {{ latToString(lat) }} -
-
`, styles: [ ` :host { height: 100%; - display: flex; } aol-map { - width: 70%; - } - - .info { - width: 28%; - padding: 1rem; - } - - .cursor-coordinates { - display: flex; - flex-direction: column; + width: 100%; + position: relative; } `, ], }) export class CursorPositionComponent { - lon = 0; - lat = 0; - - dispatchCursor(event): void { - const coordinates = event.coordinate; - this.lon = transform(coordinates, 'EPSG:3857', 'EPSG:4326')[0]; - this.lat = transform(coordinates, 'EPSG:3857', 'EPSG:4326')[1]; - } - - latToString(lat: number): string { - return toSexagesimal(lat, '', '-'); - } - - lonToString(lon: number): string { - return toSexagesimal(lon, '', '-'); - } + protected readonly toStringXY = (coord) => toStringXY(coord, 4); } - -const toSexagesimal = (value: number, positiveSuffix: string, negativeSuffix: string): string => { - const modValue = ((value + 180) % 360) - 180; - return (modValue > 0 ? positiveSuffix : negativeSuffix) + Math.abs(modValue).toFixed(6); -}; diff --git a/src/app/display-geojson-source/display-geojson-source.component.ts b/src/app/display-geojson-source/display-geojson-source.component.ts index 8058fa30..5df7fa51 100644 --- a/src/app/display-geojson-source/display-geojson-source.component.ts +++ b/src/app/display-geojson-source/display-geojson-source.component.ts @@ -1,4 +1,4 @@ -import { Component } from '@angular/core'; +import {Component} from '@angular/core'; @Component({ selector: 'app-display-geojson-source', @@ -15,17 +15,12 @@ import { Component } from '@angular/core'; - - - - - - + +
`, }) -export class DisplayGeojsonSourceComponent {} +export class DisplayGeojsonSourceComponent { +} diff --git a/src/app/display-geometry/display-geometry.component.ts b/src/app/display-geometry/display-geometry.component.ts index cc797a53..2a6baf11 100644 --- a/src/app/display-geometry/display-geometry.component.ts +++ b/src/app/display-geometry/display-geometry.component.ts @@ -14,98 +14,86 @@ import { Component } from '@angular/core'; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @for (feature of features; track $index) { + + @switch (feature.geometry.type) { + @case ('Polygon') { + + + + + + + + + } + @case ('Point') { + + + + + + + + + + + } + @case('LineString') { + + + + + } + @case ('Circle') { + + + + + + + + + } + @case ('MultiPoint') { + + + + + + + + + + + } + @case ('MultiLineString') { + + + + + } + @case ('MultiPolygon') { + + + + + + + + + } + } + + }