-
-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
755 : Map view does not update #970
755 : Map view does not update #970
Conversation
import Mapbox from 'mapbox-gl-vue' | ||
const mbxClient = require('@mapbox/mapbox-sdk') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you've got an auto-formatter or something like that. Because it unindented all the code in this script
section, we're having trouble seeing what did and did not change. Can you revert the whitespace changes so it's easier for us to review this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍
Thanks for digging into this @gamecat2d We had one or two people who worked for Mapbox helping out Ruby for Good when this feature was first added. Let me see if we can contact them for help and suggestions about the points you raised, both about adding and removing markers and about the maintenance and licensing issues for the component. It may take us a few weeks to get someone from Mapbox to respond. Hopefully it won't take too long |
As a starting point to address @gamecat2d's point about switching libraries (I haven't worked with |
+1 for the switch to GL JS if that's an option. More documentation and support from Mapbox is possible if you're building with GL JS, like this one: https://docs.mapbox.com/mapbox-gl-js/example/filter-markers/ FWIW v1 also bills by map load (when using a Mapbox basemap), the difference with v2 is that it bills by map load regardless of where your basemap tiles come from. So there'd be no difference between v1 or v2 in terms of map loads billing if you're using a Mapbox basemap. Also, the Community team can help with donated/discounted services if you're concerned about surpassing the 50k free map loads per month: https://www.mapbox.com/community/ |
Sorry for my english. Thanks @marenab and @stanleypliu for your answers ! I have one more question : What is the advantage of mapbox over leaflet especially if the tiles are Open Street Map? The code seems easier to me with leaflet to do basic things and if you don't use mapbox tiles, you don't even need to have any API key. I discovered mapbox with this project and now i'm searching what are the possible alternatives. I don't understand the pros to use a commercial product (mapbox) for this project (mutual aid). Have a great day and stay safe ! |
That's a choice for your team to make @gamecat2d. Some folks prefer to build with Leaflet, some prefer GL JS. I'd say the main advantages of GL JS are that there are more supported features / documentation and the performance of vector tiles (instead of Leaflet's raster tiles) is smoother and faster to load. But your call! If you do choose Mapbox, the Mapbox Community team can support. There is also a GL-Leaflet binding, if you'd like to build with Leaflet but bring in Mapbox vector tiles: https://github.com/mapbox/mapbox-gl-leaflet |
I've read over the comments in this thread and done some digging of my own. @finn2d — I understand your interest in using other mapping tools. If I was doing this project by myself, I might have given them a much closer look before choosing. That said, we're doing this project with the help and support of the Ruby for Good community, which means we have a lot of people who can to give support us if we stick with Mapbox. (Like @marenab and @stanleypliu! Thanks you two for jumping in on this one.) So I'd prefer to stick with Mapbox for now, if that's okay. If that leads to problems later with API billing, I'm happy to wait to solve those problems once we have them. I found that there are some more recent open source packages that tie Vue together to Mapbox, including the Mapbox GL JS tools. Since you have more experience in some of these mapping tools than I do, would you mind looking through what's available and seeing if any of them could solve our problems here while still sticking with Mapbox? Let me know what you think. And again, thanks @finn2d for spending time on this. We really appreciate it! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vurtn, thanks for working on this! 🙏🏾 . Apologies for taking so long to resolve this PR.
You raise some important concerns about the mapbox-gl-vue
library being the wrong license and unmaintained. I've documented those concerns in #993.
In the meantime, this PR appears to solve the immediate issue and is good to merge. I see some potential opportunities for minor refactorings but don't think they're worth addressing until we pick an alternative to mapbox-gl-vue
.
Thanks again! 🔥
Sorry for my english.
Why
The map view does not update when we change the filters (#755).
What
geocode
methodadd_marker
methodHow
Ouch. So... The problem is that the component is never refreshed. The change of
contributions
is made but has no impact in the component. I changed several things:First i splitted the function
loaded
to :geocode
andadd_markers
. I extracted some variables in parameters to be able to output this logic if desired in a separate file.Then I realized that the markers are added when the component is created but we don't have access to them otherwise. The wrapper documentation didn't really help me so I fetched the map via
@map-init
to see what's available. It's themapbox-gl
map. So i searched how to remove the markers on it before drawing. In the methodadd_markers
i remove the old points if they exists (source
andlayer
) before adding the new ones.I check the contributions in the watcher to avoid the whole process if they are the same.
Instead of display an empty map if there is no match, i just printed a message. The result :
Testing
I don't know how to test this.
Next Steps
Not seem to be concerned (or see the next point).
Outstanding Questions, Concerns and Other Notes
While trying to solve this issue, i wondered if it would not be good to change the library. I see 2 points to justify my point of view :
mapbox-gl-vue
is more than a year ago and the project seems abandoned.mapbox-gl-vue
isGPL-3.0 License
. On this website we can see :Accessibility
Not seem to be concerned.
Security
Not seem to be concerned.
Meta
Not seem to be concerned.
Pre-Merge Checklist
I think the reviewer will check this so i let it empty.
Best regards and stay safe !