greatly simplifies the code, and would let us close
[[replace openlayers with leaflet]]
and
-[[osm plugin fails to display map with javascript error]]
+[[bugs/osm plugin fails to display map with javascript error]],
at the cost of removing some features.
The branch already incorporates changes from my review and additional fixes.