Public Lab
Update initializers to class factory syntax
The problem
What's supposed to happen:
From the official Leaflet docs:
Class Factories
You may have noticed that Leaflet objects are created without using the new keyword. This is achieved by complementing each class with a lowercase factory method:
new L.Map('map'); // becomes:
L.map('map');
What actually does happen:
We use built-in Leaflet classes such as L.Control.Layers, L.Map, and L.LatLng, but we don't take advantage of their suggested class factory syntax. Let's clean up the below file a bit to do that:
Solution
- remove the
newkeyword and change the initializer toL.maphttps://github.com/publiclab/mapknitter/blob/fb876407671f27e0bc97cb9da1edb2baa8797ac0/app/views/map/_leaflet.html.erb#L57 - remove the
newkeyword and change the initializer toL.control.layershttps://github.com/publiclab/mapknitter/blob/fb876407671f27e0bc97cb9da1edb2baa8797ac0/app/views/map/_leaflet.html.erb#L70 - remove the
newkeyword and change the initializer toL.latLnghttps://github.com/publiclab/mapknitter/blob/fb876407671f27e0bc97cb9da1edb2baa8797ac0/app/views/map/_leaflet.html.erb#L73
Additional Information
Please find further information on installation, solving, & getting help on the linked issue.
Thank You 😊
Task tags
Students who completed this task
VladeDev