Open iagomoliv opened 4 days ago
I like this suggestion @iagomoliv! To avoid breaking existing code, the new parameter would probably be added at the end (or just before callback
which was added very recently). Something like:
snazzy.addStyle(url, alias, map, callback?);
The implementation is a little tricky, but should be possible. Some details below for my own reference.
To allow multiple custom styles, snazzy stores all the active styles in an object and adds them to the map together. With multiple maps, each map will need its own set of active styles. They can't be set as properties of the map object because the default Map
is not extensible, and the map instance can't be used as an object key because they just stringify to "[object Object]". An association list with [ui.Map, [style]]
pairs might be the best approach.
Current behavior
Currently, the module only works with the default
Map
instance. Users cannot use the module's functions with custom map instances created viaui.Map()
.Proposed enhancement
Add an optional
map
parameter to the module's functions. When not specified, it defaults to the standardMap
.Example