Monday, August 6, 2012

Leaflet 0.4, Tried and Failed !

This big app I've been writing lately, has been in Leaflet 0.3 I was urged to upgrade to 0.4 for a few minor things: panning intertia, the Retina support, the new Control.Scale which is prettier than mine, and general bugfixes.

But it didn't work out, despite my careful reading and note-taking of the Breaking Changes.

On my Android (2.3.6 on a LG Spectrum), I had serious problems.
  • Inertia didn't work at all.
  • Animations didn't happen anymore; apparently this is intentional but they worked in 0.3.
  • After loading, the map would become obscured by something, a DIV I couldn't identify, and would only reappear after I click the zoom out button, though tapping would perform click-queries and show popups over the blankness.
  • The window.scrollTo() trick to hide the address bar, caused the page to flash annoyingly for some 15 seconds.
  • And then it crashed the browser completely.
So yeah, at least for this non-trivial mobile app, Leaflet 0.3 is where we'll stay.

Unfortunately, Android was the last of the platforms I tested, and the app did work perfectly on Desktop, and on the iPad 4. So in the meantime I did discover two features which may not have been entirely clear from the "breaking changes" guide:
  • Layers can now be given an explicit "zIndex" property in the constructor options. Excellent! Less excellent, is that you must do this or else the layers stack randomly; in my case, the basemaps came in on top completely obscuring the overlay layers. I know, it's not the documented behavior and they should have stacked in the order they were added, but I could make the randomness happen reliably here.
  • Markers can no longer have "draggable" set unless "clickable" is also set. Not a problem, but it did cost me some 15 minutes. True to their word, clickable:false means NO mouse events, and I can see where this is a win for efficiency.

No comments:

Post a Comment