Skip to content

Commit

Permalink
Bugfix JS: OL2 getLonLatFromPixel can return null
Browse files Browse the repository at this point in the history
Fixed
```
Uncaught TypeError: mE.lizmap3.map.getLonLatFromPixel(...) is null
    _mousemove MousePosition.js:120
```
  • Loading branch information
rldhont committed Dec 1, 2023
1 parent a2f88c5 commit 5822c71
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion assets/src/components/MousePosition.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ export default class MousePosition extends HTMLElement {
let lon,lat;
// OL2
if(evt.xy){
({ lon, lat } = mainLizmap.lizmap3.map.getLonLatFromPixel(evt.xy));
const lonlat = mainLizmap.lizmap3.map.getLonLatFromPixel(evt.xy);
if (lonlat !== null) {
lon = lonlat.lon;
lat = lonlat.lat;
}
} else if (evt.pixel){ //OL6
[lon, lat ] = mainLizmap.map.getCoordinateFromPixel(evt.pixel);
}
Expand Down

0 comments on commit 5822c71

Please sign in to comment.