Sometimes L.Map.getSize return size with zero #275

Closed
olexandrp opened this Issue Sep 1, 2011 · 5 comments

Comments

Projects
None yet
2 participants
@olexandrp

I use Leaflet map in modal window on page. Sometimes, on opening this modal window with map - viewport of map appears empty. This behavior can be reproduced when browser window have some special sizes.

I solve this problem by extending check in L.Map.getSize for this._size. When variable this._size set to x:0, y:0 - such problem with viewport appear.

My solution is:

old code

getSize: function() {
    if (!this._size || this._sizeChanged) {
    ...

new code

getSize: function() {
    if (!this._size || !this._size.x || !this._size.y || this._sizeChanged) {
    ...

Maybe someone have better solution or code changes must be in other place?
Any suggestions, thanx.

@mourner

This comment has been minimized.

Show comment
Hide comment
@mourner

mourner Sep 1, 2011

Member

Try calling map.invalidateSize() after opening the window, it should solve the issue.

Member

mourner commented Sep 1, 2011

Try calling map.invalidateSize() after opening the window, it should solve the issue.

@olexandrp

This comment has been minimized.

Show comment
Hide comment
@olexandrp

olexandrp Sep 2, 2011

Many thanks, I'll check and report here.

Many thanks, I'll check and report here.

@mourner

This comment has been minimized.

Show comment
Hide comment
@mourner

mourner Sep 8, 2011

Member

So?

Member

mourner commented Sep 8, 2011

So?

@mourner

This comment has been minimized.

Show comment
Hide comment
@mourner

mourner Sep 8, 2011

Member

I'll close the issue and reopen it if there's still any trouble.

Member

mourner commented Sep 8, 2011

I'll close the issue and reopen it if there's still any trouble.

@mourner mourner closed this Sep 8, 2011

@olexandrp

This comment has been minimized.

Show comment
Hide comment
@olexandrp

olexandrp Sep 12, 2011

Sorry for so late response - a lot of vacations.
map.invalidateSize() help in solving this problem.
Many thanx.

Sorry for so late response - a lot of vacations.
map.invalidateSize() help in solving this problem.
Many thanx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment