Skip to content

Commit

Permalink
fix: wrong calculation to get the initial view of map for planters Gr…
Browse files Browse the repository at this point in the history
…eenstand#153

(without spin changes)
  • Loading branch information
SuokN committed Jan 24, 2023
1 parent c9210ac commit 875b4b5
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export default class Map {
}

constructor(options) {
const mapCanvas = document.getElementById('map-canvas')
// default
const mapOptions = {
...{
Expand All @@ -47,8 +46,6 @@ export default class Map {
tileServerUrl: 'https://{s}.treetracker.org/tiles/',
tileServerSubdomains: ['dev-k8s'],
apiServerUrl: 'https://dev-k8s.treetracker.org/webmap/',
width: mapCanvas == null ? window.innerWidth : mapCanvas.clientWidth,
height: mapCanvas == null ? window.innerHeight : mapCanvas.clientHeight,
debug: false,
moreEffect: true,
filters: null,
Expand Down Expand Up @@ -905,6 +902,12 @@ export default class Map {
this.events.emit(Map.REGISTERED_EVENTS.MOVE_END)
})

this.map.on('resize', (e) => {
log.warn('resize', e)
this.width = e.newSize.x
this.height = e.newSize.y
})

// button prev next
{
// next tree buttons
Expand Down Expand Up @@ -1278,7 +1281,10 @@ export default class Map {

// load google map
await this._loadGoogleSatellite()

const mapCanvas = document.getElementById('map-canvas')
this.width = mapCanvas == null ? window.innerWidth : mapCanvas.clientWidth
this.height =
mapCanvas == null ? window.innerHeight : mapCanvas.clientHeight
// /*
// * The logic is:
// * If there is a filter, then try to zoom in and set the zoom is
Expand Down

0 comments on commit 875b4b5

Please sign in to comment.