Closed nathonius closed 1 year ago
Marker file name setting? I wasn't sure if this would be overkill.
I agree, this is overkill. Forcing people to use a markers.json filename is good with me.
Fix the bug described below.
This happens because the post processor assumes the renderer creates the map directly in the same event loop call.
By adding in the asynchronous call before the map creation, the registerMapEvents
call happens before the renderer's map
is created (because the await takes it out of the event loop, to be executed later, after the promise returns).
I think the best solution would be to move the registerMapEvents
call to the renderer instead, and register them in the buildMap
flow. There's nothing about them that can't be done in the renderer and then it's more explicit.
Honestly, the whole post processor could be cleaned up a lot. The code is a mess unfortunately, kudos for being willing to dive into it lol
I think the best solution would be to move the registerMapEvents call to the renderer instead, and register them in the buildMap flow. There's nothing about them that can't be done in the renderer and then it's more explicit.
Honestly, the whole post processor could be cleaned up a lot. The code is a mess unfortunately, kudos for being willing to dive into it lol
Well that wasn't the only place trying to access the map synchronously. š It was also being accessed inside the onload
of the renderer itself. Rather than trying a large scale refactor, I added a safety measure to allow those places (which are luckily already async) to wait on the map to be built first.
As a test, I replaced all my marker types defined in settings (10 types), with a local file. And my map with all those markers still rendered just fine. š
Slightly WIP, there's one issue I've yet to solve. Was hoping to get some feedback on this. First, a summary:
markers.json
markers.json
file should be an array of marker types with the exact same syntax as the markers stored in plugin settingsStill to-do / feedback requested:
Currently, the marker file is read after the map is created:
This causes markers of types defined in the json file to not render correctly until they are edited or otherwise re-rendered, since the marker types aren't available when the map is first constructed. Originally I tried to read the file before creating the map and then passing any additional markers as one of the option parameters, but something about awaiting ANY async call before the map is created causes the plugin to error out. This code throws this error:
I've really got no clue why awaiting any promise (even an already resolved promise) would cause this, was hoping to get a second pair of eyes on that. My assumption is that somewhere someone is trying to access the map synchronously and introducing the await causes it to be instantiated in a later cycle. But I wasn't able to find the source of the issue.