svelte-mapbox icon indicating copy to clipboard operation
svelte-mapbox copied to clipboard

ready event on <Map> not firing anymore on 8.1.1

Open evdama opened this issue 2 years ago • 8 comments

I'm on Sapper 0.29.2 where I've worked on a map over the last few days using the following code where on:ready fired as expected:

              <Map
                accessToken=ROLLUP_MAPBOX_EDM_DEFAULT_PUBLIC_ACCESS_TOKEN
                bind:this={ mapComponent }
                bind:zoom
                on:click={ toggleStyle }
                on:ready={ () => console.log('inline ready event...') }
                on:dragend={ colorizeBuildings }
                on:dragend={ showUrbanAreas }
                on:zoomend={ colorizeBuildings }
                on:zoomend={ showUrbanAreas }
                on:zoomstart={ toggleStyle }
                options={{ attributionControl: false, antialias: true }}
                style = { $userStore.userCurrenMapBoxTheme }
              >
  1. However, after upgrading from 7.7.1 to 8.1.1 on:ready doesn't fire anymore i.e in the above snippet console.log() never prints to the console? 🤔
  2. What I also noticed just now is that bind:zoom stopped working i.e. using { zoom } somewhere on the page to show the user his current zoom level worked in 7.7.1 but stopped working after upgrading to version 8.1.1

@antony does on:ready work for you at this point i.e. using 8.1.1? I just went back to 7.7.1 and all works again, no change to my source, just downgrading svelte-mapbox 🤷‍♂️

evdama avatar Jul 21 '21 11:07 evdama

Hey @evdama - it's possible I broke some events, and it looks like, possibly broke the zoom binding.

I'll try to fix these issues asap.

antony avatar Jul 23 '21 09:07 antony

Ok, I've fixed the events, not sure how to handle the bindings at all since it all lives inside an action now, and that means I can't do anything reactive. that needs some thought I guess.

I considered putting all the values in stores - so maybe I'll be able to do this sometime soon, but I don't have time right now.

antony avatar Jul 23 '21 10:07 antony

Excellent, thanks much!

Another nice event to have would be dragstart next to dragend https://github.com/beyonk-adventures/svelte-mapbox/blob/4d804dd2a8534e2017c5de426f4a648add76ce3f/src/lib/map/map-action.js#L38

Also, why is moveend called recentre? Why not take the event names as-is from mapbox-gl-js? Just curios 😄 https://github.com/beyonk-adventures/svelte-mapbox/blob/4d804dd2a8534e2017c5de426f4a648add76ce3f/src/lib/map/map-action.js#L44

evdama avatar Jul 23 '21 12:07 evdama

Ok, I've fixed the events, not sure how to handle the bindings at all since it all lives inside an action now, and that means I can't do anything reactive. that needs some thought I guess.

Yes, ok, the Readme still mentions bindings i.e. somebody installing svelte-mapbox today would be very confused as it's not working as described.

I considered putting all the values in stores - so maybe I'll be able to do this sometime soon, but I don't have time right now.

Roger Roger... It's just really really nice if you can show reactively updated values to the user such as

<div class="flex flex-row justify-center">Your Current Zoom Level: { zoom }</div>

evdama avatar Jul 24 '21 12:07 evdama

Yep - I'll have a think on this or wait for somebody smarter to come up with a solution!

antony avatar Jul 29 '21 08:07 antony

@antony What do you think about having dragstart like mentioned above?

evdama avatar Aug 05 '21 12:08 evdama

@evdama If it's useful, then yeah I think dragstart would be a useful event.

antony avatar Nov 01 '21 22:11 antony

just boosting this here, as in mapbox ^9.1.0 the zoom and center bindings still do not work :(

jesi-rgb avatar Dec 25 '23 09:12 jesi-rgb