Skip to content

Commit

Permalink
Fix scale values to match those defined in plugin
Browse files Browse the repository at this point in the history
Scales are those defined in Lizmap plugin when there is
 no EPSG:3857 base layers defined
Fix 3liz#1938
  • Loading branch information
nboisteault committed Dec 14, 2020
1 parent 2a7aaf9 commit b7f00ef
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
9 changes: 8 additions & 1 deletion assets/src/components/Scaleline.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@ export default class Scaleline extends HTMLElement {
}

connectedCallback() {

// DPI is adjusted here because this commit https://github.com/openlayers/openlayers/commit/857f4e01ac9c6c27d83f7cc1f5eda86c53405228
// has not been released yet. Also we use 25.40005080010160020 as it is more precise
// TODO : Change this value when commit released and Lizmap up to date with OL 6
const ADJUSTED_DPI = (96 * 1000) / (25.40005080010160020 * 39.37);

this._olScaleline = new ScaleLine({
target: this,
minWidth: 76,
bar: true,
text: true
text: true,
dpi: ADJUSTED_DPI
});

mainLizmap.map._olMap.addControl(
Expand Down
5 changes: 5 additions & 0 deletions assets/src/modules/Lizmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ export default class Lizmap {
}
register(proj4);

// Override getPointResolution method to always return resolution
// without taking care of geodesic adjustment as it can be confusing for user to not have rounded scales
(getProjection(this.projection)).setGetPointResolution((resolution) => resolution);
(getProjection(this.config.options.qgisProjectProjection.ref)).setGetPointResolution((resolution) => resolution);

// Create Lizmap modules
this.map = new Map();
this.edition = new Edition();
Expand Down
3 changes: 1 addition & 2 deletions assets/src/modules/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ export default class Map {
view: new View({
center: [0, 0],
zoom: 2,
projection: mainLizmap.projection,
constrainResolution: true
projection: mainLizmap.projection
}),
target: 'newOlMap'
});
Expand Down

0 comments on commit b7f00ef

Please sign in to comment.