Skip to content

Map stops working if the map is re-centered right after the map initialization. #2071

@MacWeber

Description

@MacWeber

updated as of comment #2071 (comment)

Issue summary

Map stops working (loading tiles) if map is recentered the map is created. This issue happens only when a starting map (including tile layer, center, and zoom) is available.
Adding a 1ms delay avoids this bug.

(I've realized it with L.geoJson layer in addion to L.tileLayer, not sure if it also happens with other layer types)

How to reproduce

(updated as of comment #2071 (comment) )
It took me a long time and many trials to make the JS fiddle because the same coordinates was not buggy on the fiddle. Using different coordinates lead the bug on JS fiddle.
I also realize that adding more random scripts to the scripts stack may avoid the bug.

Buggy fiddle:

http://jsfiddle.net/Sa7bq/9/

There 4 ways to avoid the bug:

  • Comment the lines 12 and 13 (center and zoom). Example:
    http://jsfiddle.net/Sa7bq/10/
  • Uncomment line 54 to create a 1ms delay before re-centering the map. Example:
    http://jsfiddle.net/Sa7bq/11/
  • Different coordinates may lead to bug or not in different machines. In may local machine I have the features using the coordinates [-43.9281714, -19.8756538] and [-43.9373343, -19.9240936], leading to the bug. However, in jsfiddle the I got the bug changing the second coordinate to [-43.9373343, -19.8756538]. Example of bug not happening anymore by just switching the coordinate on lines 47 and 48:
    http://jsfiddle.net/Sa7bq/12/
  • As I said before, adding more random scripts to the stack may also avoid the bug.
    I could not reproduce this behavior on jsfiddle, However, in my local machine, adding jQuery UI and jQuery UI autocomplete avoided the bug.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions