jieter / Leaflet.Sync

Synchronized view of two maps.
http://jieter.github.io/Leaflet.Sync/examples/dual.html
BSD 3-Clause "New" or "Revised" License
235 stars 53 forks source link

Problem in goldenlayout #50

Closed fsteinmetz closed 6 years ago

fsteinmetz commented 6 years ago

There is a problem when using Leaflet.Sync in Golden-Layout.

    at r (L.Map.Sync.js:193)
    at e.setView (L.Map.Sync.js:206)
    at e._selfSetView (L.Map.Sync.js:150)
    at e.fireEvent (leaflet.js:6)
    at e.invalidateSize (leaflet.js:6)
    at Object.<anonymous> ((index):112)
    at e.LayoutManager.emit (goldenlayout.min.js:1)
    at e.items.Root._propagateEventToLayoutManager (goldenlayout.min.js:2)
    at goldenlayout.min.js:1

See the following fiddle : https://jsfiddle.net/frstz/563wsxp7/5/

jjimenezshaw commented 6 years ago

Just looking at the code (I have not tried it), I would replace

if (options && options.disableViewprereset) {

with

var doit = options && options.disableViewprereset && obj && obj._events;
if (doit) {

(the if statement in two places)

fsteinmetz commented 6 years ago

Indeed I have tested and it works. Should probably be adopted as an immediate solution.

But this still leaves an annoying flicker that is mentioned in the comment. Any idea how to deal with it ?

fsteinmetz commented 6 years ago

Fiddle updated with new release 0.2.2 which fixes the bug but leaves the flicker. https://jsfiddle.net/frstz/563wsxp7

jjimenezshaw commented 6 years ago

@fsteinmetz Have you tried with the last version of Leaflet (1.2.0)? The hack to avoid the flicker is not working properly on 0.7.

In summary: we have to do a "reset" to locate properly the tiles, but do not reload all the tiles (that causes the flicker). In 1.2.0 it is done hacking the event viewprereset, that runs _invalidateAll, but in 0.7 I do not see any way. Suggestions are welcome.

fsteinmetz commented 6 years ago

Indeed it works perfectly with Leaflet 1.2.0 I didn't notice I wasn't using the latest version. Fiddle updated with Leaflet 1.2.0 : https://jsfiddle.net/frstz/563wsxp7 Thanks for your help, using Leaflet.Sync in GoldenLayout really opens up awesome possibilities. I'm closing the issue :)