Skip to content
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

Document Maplibre patterns #339

Open
derekeder opened this issue Jul 21, 2023 · 6 comments
Open

Document Maplibre patterns #339

derekeder opened this issue Jul 21, 2023 · 6 comments
Assignees
Labels

Comments

@derekeder
Copy link
Member

Background

We've been using Leaflet.js and CARTO for our interactive maps for many years now. After working on a side project that leverages mapbox-gl and kepler.gl (https://ilsolarmap.com), I see there are some potentially big advantages to making maps with Mapbox-GL, including:

  • renders data as vectors instead of tile images, yielding higher resolution and more programmatic control over the display of data
  • GeoJSON data is converted into vector data, allowing for much larger files to be rendered (100+mb files in the browser)
  • smooth zooming
  • faster load times
  • support for 3D visualizations

Our current pattern for rendering GeoJSON data has some pretty hard limits. Anything over 1mb or with over 1,000 features starts to get very slow in Leaflet. In this case, we have switched over to CARTO to render large files, but the switch can be awkward and the plan we are on has limited space and the latest plans are 10x more expensive. If Mapbox GL works out, we can potentially drop our dependence on CARTO and serve all of our map data directly in the browser.

Proposal

I'll create a test project using Mapbox-GL following their tutorials & documentation with some larger data: https://docs.mapbox.com/mapbox-gl-js/guides/

I will also try out a project using React Map GL, a React wrapper for Mapbox GL: https://visgl.github.io/react-map-gl/

Deliverables

I'll summarize my experience and findings and share them back on this thread along with a recommendation on next steps.

Timeline

Probably a day or so

@derekeder derekeder added the R&D label Jul 21, 2023
@derekeder derekeder self-assigned this Jul 21, 2023
@derekeder
Copy link
Member Author

derekeder commented Jul 26, 2023

There is an alternative library that does mapping with vector tiles called MapLibre: https://maplibre.org/maplibre-gl-js/docs/

It looks to be a fork of mapbox-gl and has many of the same features. The biggest difference that I can tell so far is mapbox gives easier access to nice looking vector tile basemaps.

ArcGIS offers some vector tile basemaps of their own and have documentation on how to use them with maplibre: https://developers.arcgis.com/maplibre-gl-js/maps/change-the-basemap-style-v2/

@derekeder
Copy link
Member Author

I have my first working map using Mapbox-GL: https://ilsolarmap.com/

Screen Shot 2023-08-04 at 10 35 42 AM

The map code is here:

I implemented using plain javascript with bootstrap and jquery. The map features:

  • toggling between 5 different geographic levels, two of them (tracts & places) over 2mb in size with over 2,000 features, which render and load just fine
  • toggling between 5 different categories, each which dynamically change the shading in the map
  • map hover interactivity with a tooltip and border outline

Things to note / differences with Leaflet:

@smcalilly
Copy link
Contributor

smcalilly commented Aug 9, 2023

Next steps:

  • try out in a client project
  • see how well it works with React

@smcalilly
Copy link
Contributor

smcalilly commented Aug 10, 2023

this blog post might be a good place to research mapbox + react? https://evilmartians.com/chronicles/how-to-build-a-better-react-map-with-pigeon-maps-and-mapbox

this tool was used in that post, seems kind of interesting: https://pigeon-maps.js.org/ from their docs:

Are you tired of waiting 3 seconds to parse 200kb of Google Maps JavaScript just to display a few tiles and a marker? 140kb of minified Leaflet too much?

Welcome to the club!

@derekeder derekeder assigned antidipyramid and fgregg and unassigned derekeder Jan 24, 2024
@fgregg
Copy link
Member

fgregg commented Jan 24, 2024

you can use other basemaps, including raster ones:

https://docs.mapbox.com/mapbox-gl-js/example/map-tiles/

@smcalilly
Copy link
Contributor

@antidipyramid is doing this for a DPD project, has positive first impressions.

@antidipyramid antidipyramid changed the title Try out Mapbox-GL Document Maplibre patterns Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants