Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feat): GSGGR-186 Make it possible to define default extent from an url #46

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 23 additions & 19 deletions src/app/_services/map.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Draw, Modify } from 'ol/interaction';
import { Feature } from 'ol';
import { FeatureLike } from 'ol/Feature';
import Polygon, { fromExtent } from 'ol/geom/Polygon';
import WMTS, {Options} from 'ol/source/WMTS';
import WMTS, { Options } from 'ol/source/WMTS';
import WMTSTileGrid from 'ol/tilegrid/WMTS';
import { register } from 'ol/proj/proj4';
import DragPan from 'ol/interaction/DragPan';
Expand Down Expand Up @@ -49,6 +49,7 @@ import { DragAndDropEvent } from 'ol/interaction/DragAndDrop';
import { shiftKeyOnly } from 'ol/events/condition';
import { createBox } from 'ol/interaction/Draw';
import { CoordinateSearchService } from './coordinate-search.service';
import { ActivatedRoute } from '@angular/router';

@Injectable({
providedIn: 'root'
Expand Down Expand Up @@ -123,6 +124,7 @@ export class MapService {

constructor(
private configService: ConfigService,
private route: ActivatedRoute,
private coordinateSearchService: CoordinateSearchService,
private store: Store<AppState>,
private snackBar: MatSnackBar,
Expand All @@ -136,23 +138,26 @@ export class MapService {
// @ts-ignore
this.map = null;
}
this.initializeMap().then(() => {

this.initializeDrawing();
this.initializeInteraction();
this.initializeDragInteraction();
this.initializeDelKey();
this.store.select(selectOrder).subscribe(order => {
if (!this.featureFromDrawing && order && order.geom) {
const geometry = this.geoJsonFormatter.readGeometry(order.geom);
const feature = new Feature(geometry);
this.drawingSource.addFeature(feature);
}
});
this.route.queryParamMap.subscribe(params => {
this.initialExtent = params.get("initialExtent")?.split(",", -1).map(parseFloat) ?? this.configService.config!.initialExtent;
console.log(this.initialExtent);
this.initializeMap().then(() => {
this.initializeDrawing();
this.initializeInteraction();
this.initializeDragInteraction();
this.initializeDelKey();
this.store.select(selectOrder).subscribe(order => {
if (!this.featureFromDrawing && order && order.geom) {
const geometry = this.geoJsonFormatter.readGeometry(order.geom);
const feature = new Feature(geometry);
this.drawingSource.addFeature(feature);
}
});

this.initialized = true;
}).catch(() => {
this.initialized = true;
this.initialized = true;
}).catch(() => {
this.initialized = true;
});
});
}

Expand Down Expand Up @@ -238,7 +243,7 @@ export class MapService {
public async createTileLayer(baseMapConfig: IBasemap, isVisible: boolean): Promise<TileLayer<TileSource> | undefined> {
if (!this.resolutions || !this.initialExtent) {
this.resolutions = this.configService.config!.resolutions;
this.initialExtent = this.configService.config!.initialExtent;

await this.debounce(200);
}
const matrixIds = [];
Expand Down Expand Up @@ -355,7 +360,6 @@ export class MapService {
+ '+towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs');
register(proj4);

this.initialExtent = this.configService.config.initialExtent;
this.resolutions = this.configService.config.resolutions;
this.projection = new Projection({
code: EPSG,
Expand Down