Skip to content

Commit

Permalink
Use OL10 map instead of OL2 for actions (#4743)
Browse files Browse the repository at this point in the history
  • Loading branch information
nboisteault authored Sep 12, 2024
1 parent a85e8d4 commit 476af77
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions assets/src/modules/Action.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import { mainLizmap } from '../modules/Globals.js';
import { Vector as VectorSource } from 'ol/source.js';
import { Vector as VectorLayer } from 'ol/layer.js';
import GeoJSON from 'ol/format/GeoJSON.js';
import Point from 'ol/geom/Point.js';
import { fromExtent } from 'ol/geom/Polygon.js';
import WKT from 'ol/format/WKT.js';

/**
* @class
Expand Down Expand Up @@ -388,12 +391,13 @@ export default class Action {

// We add the map extent and center
// as WKT geometries
let extent = mainLizmap.lizmap3.map.getExtent().clone();
extent = extent.transform(mainLizmap.lizmap3.map.getProjection(), 'EPSG:4326');
options['mapExtent'] = extent.toGeometry().toString();
let center = mainLizmap.lizmap3.map.getCenter().clone();
center = center.transform(mainLizmap.lizmap3.map.getProjection(), 'EPSG:4326');
options['mapCenter'] = `POINT(${center['lon']} ${center['lat']})`;
const WKTformat = new WKT();
const projOptions = {
featureProjection: mainLizmap.projection,
dataProjection: 'EPSG:4326'
};
options['mapExtent'] = WKTformat.writeGeometry(fromExtent(mainLizmap.extent), projOptions);
options['mapCenter'] = WKTformat.writeGeometry(new Point(mainLizmap.center), projOptions);

// Request action and get data
let url = actionConfigData.url;
Expand Down

0 comments on commit 476af77

Please sign in to comment.