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

MapLibre basemap #2461

Merged
merged 16 commits into from
Dec 19, 2023
Merged

MapLibre basemap #2461

merged 16 commits into from
Dec 19, 2023

Conversation

birkskyum
Copy link
Collaborator

@birkskyum birkskyum commented Nov 30, 2023

closes #2460 cc @ibgreen

This makes the initial move to maplibre, to get the ball rolling, but it's not complete yet as outlined below. The demo app appear to work just fine. The examples folder doesn't use the local build, but instead a pinned kepler.gl version, so I haven't tried all of them yet.

New styles (and thumbnails) will be needed to replace the "uberdata" ones, since the mapbox styles with their proprietary mapbox:// syntax aren't supported. That is an area I'll need your help with completing. I made a quick darkblue style with maptiler, which is shown in the image below, and carto also has some free ones available (added the dark-matter one).

The GPU layers should work as well now in supported browsers, because maplibre v3 has webgl2 support, and a webgl1 fallback.

Screenshot 2023-11-30 at 20 24 27

@birkskyum birkskyum force-pushed the maplibre-basemap branch 2 times, most recently from 6eb76ca to ac5a62a Compare November 30, 2023 19:29
@birkskyum birkskyum marked this pull request as ready for review November 30, 2023 19:45
@ibgreen
Copy link
Collaborator

ibgreen commented Nov 30, 2023

That was quick. I will try to get reviewers eyes on to this asap!

There was a luma.gl patch version mismatch 8.5.20/21, which takes a lot of space in this pr. Is the plan to include deck.gl/luma.gl v9 in this upcoming release?

No, the deck v9 upgrade is going to be the base of the kepler.gl 4.0 release. It is going to require a major lift.

@@ -104,7 +104,7 @@ function App() {
/>
<link
rel="stylesheet"
href="http://api.tiles.mapbox.com/mapbox-gl-js/v1.1.1/mapbox-gl.css"
href="https://unpkg.com/maplibre-gl@^3/dist/maplibre-gl.css"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: Have you tested the jupyter integration?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, in general I had a hard time running the examples and would love some help with that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can I test the jupyter bindings locally?

@@ -22,8 +22,8 @@ import React from 'react';
import ReactDOM from 'react-dom/client';
import document from 'global/document';
import {Provider} from 'react-redux';
import store from './store';
import App from './app';
import store from './store.ts';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you have some editor that auto sorts imports, package.json etc (or perhaps it just your good habita). But this makes the PR bigger than it has to be and can conflict with other users. Is it possible to avoid these changes? Alternatively get those landed first so the functional change set is smaller.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I tried to run this example, and got an error that it couldn't find the 'store' and 'app', and it worked when I added the extensions. Will make a PR just for that, and some of the other minor changes that are unrelated to maplibre.

import keplerGlReducer, {enhanceReduxMiddleware} from '@kepler.gl/reducers';
import { configureStore } from '@reduxjs/toolkit';
import { StoreEnhancer } from 'redux';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@macrigiuseppe Need your review on these redux changes.

Copy link
Collaborator Author

@birkskyum birkskyum Nov 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for context - createStore had a deprecation warning, and a IDE note to use configureStore. It's another thing that can be pulled to another PR if it's easier, because there are many other cases where the createStore is used.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2023-11-30 at 22 14 44

@@ -1,3 +1,23 @@
// Copyright (c) 2023 Uber Technologies, Inc.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was contributed recently long after Uber stopped contributing and transferred ownership to OpenJS foundation. @igorDykhta @macrigiuseppe I assume it is an automated script that adds this, can we disable that?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenJS Foundation council clarified we no longer need to carry forward the Uber copyright and instead use "Copyright contributors to the kepler.gl project" (without years)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened #2467

colorMode: BASE_MAP_COLOR_MODES.NONE
}

// {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@macrigiuseppe I assume we do need counterparts to all of these in order to load saved maps?

@ibgreen ibgreen requested review from ilyabo and removed request for macrigiuseppe December 5, 2023 21:04
@@ -315,47 +315,57 @@ export const DEFAULT_MAP_STYLES: {
{
id: 'dark',
label: 'Dark',
url: 'mapbox://styles/uberdata/cjoqbbf6l9k302sl96tyvka09',
url: 'https://api.maptiler.com/maps/b989b458-e075-497d-9a86-3035fd08bd7c/style.json?key=17oUJVO01Blh1QOfWftj',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe at least the default should be Carto's Dark Matter. It doesn't look that pretty, but it doesn't require setting up an account and creating styles by any particular user. Using a MapTiler account would imply map load limits on their free tier.

Alternatively, we could try to reach out to MapTiler (they say that they love open-source) asking to provide an unlimited key for kepler.

@heshan0131 what do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reaching out to maptiler seems like a nice thing to do, however in the interest of landing this PR quickly, I would say let's keep things separate and let's just add the unconstrained CARTO styles as defaults for now.

Ideally, users of the kepler.gl framework can easily reconfigure the styles.

@@ -141,15 +141,16 @@ const MAPBOXGL_STYLE_UPDATE = 'style.load';
const MAPBOXGL_RENDER = 'render';
const nop = () => {};

const MapboxLogo = () => (
const MapLibreLogo = () => (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should use react-map-gl's AttributionControl instead. Right now there's no mention of MapTiler or Carto in the attribution when their maps are used. I assume that would mean breaching their licenses.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be not a logo but a small attribution text (this is from a deck.gl example ).
image.

For some reason this seems to have been lost in the kepler.gl baseline (presumably not an issue with this PR): #2462. If so we could land this and fix that separately. Or fix that first, and rebase to make sure maplibre doesn't clobber it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we remove this code in styled-components.tsx (which hides the default attribution):

   .maplibregl-ctrl-attrib {
      display: none;
    }

and then also remove this in map-container.tsx:

{this.props.primary ? (
            <Attribution
              showMapboxLogo={this.state.showMapboxAttribution}
              showOsmBasemapAttribution={true}
              datasetAttributions={datasetAttributions}
            />
          ) : null}

Then the default attribution will show up:
image

Copy link
Collaborator

@ilyabo ilyabo Dec 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or for dark matter:

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using AttributionControl is actually not required for that. Only if we want to add customAttribution.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyways, we should probably rework the attribution rendering, and it can be done in a separate PR.

@ibgreen
Copy link
Collaborator

ibgreen commented Dec 6, 2023

@birkskyum can you update the styles to use CARTO's free basemaps? https://github.com/CartoDB/basemap-styles

  • DarkMatter
  • DarkMatterNoLabels
  • Positron
  • PositronNoLabels
  • Voyager
  • VoyagerNoLabels

@birkskyum
Copy link
Collaborator Author

birkskyum commented Dec 6, 2023

@birkskyum can you update the styles to use CARTO's free basemaps? https://github.com/CartoDB/basemap-styles

It's updated now, and will load DarkMatter by default to avoid a white blank canvas.

@ibgreen
Copy link
Collaborator

ibgreen commented Dec 7, 2023

@birkskyum Looks like we are starting to get approvals. To prepare for landing, we should get CI to run green.

  • To fix the DCO issue you should just need to sign your commits before pushing. git commit --signoff
  • @ilyabo Are you able to provide some advice on what is going wrong with the Node tests?

@birkskyum
Copy link
Collaborator Author

birkskyum commented Dec 7, 2023

@birkskyum Looks like we are starting to get approvals. To prepare for landing, we should get CI to run green.

  • To fix the DCO issue you should just need to sign your commits before pushing. git commit --signoff
  • @ilyabo Are you able to provide some advice on what is going wrong with the Node tests?

There are a few things:

  • A small mock has been added to account for missing worker access in the test environment (potentially jsdom-worker could be used here instead of a mock).
  • The map styles in the tests should be updated to the carto styles. I'll look into that today. This is mainly in the mapStyleReducer, where tests breaking in relation to topMapStyle / bottomMapStyle. I'm not sure how to resolve them yet.

@birkskyum
Copy link
Collaborator Author

birkskyum commented Dec 7, 2023

I don't fully understand the remaining "smoothie_the_cat" / bottomMapStyle / topMapStyle tests that are failing. If anyone has experience or input to that, it would be appreciated.

@ibgreen
Copy link
Collaborator

ibgreen commented Dec 7, 2023

I don't fully understand the remaining "smoothie_the_cat" / bottomMapStyle / topMapStyle tests that are failing. If anyone has experience or input to that, it would be appreciated.

@igorDykhta can you look at these?

@birkskyum
Copy link
Collaborator Author

birkskyum commented Dec 7, 2023

Interesting, locally I only have the 7 tests failing from MAP_STYLE_CHANGE, but on CI there are 26... don't know what causes the difference.

@birkskyum birkskyum force-pushed the maplibre-basemap branch 2 times, most recently from fdf3ab0 to 1aa4cd9 Compare December 18, 2023 12:06
@birkskyum
Copy link
Collaborator Author

birkskyum commented Dec 18, 2023

Rebased. To ease the review have I reduce the number of changes in this PR, by bumping luma.gl separately (#2463), and reverting some changes caused by IDE auto-formatting.

Signed-off-by: Birk Skyum <birk.skyum@pm.me>
Signed-off-by: Birk Skyum <birk.skyum@pm.me>
Signed-off-by: Birk Skyum <birk.skyum@pm.me>
Signed-off-by: Birk Skyum <birk.skyum@pm.me>
Signed-off-by: Birk Skyum <birk.skyum@pm.me>
Signed-off-by: Birk Skyum <birk.skyum@pm.me>
Signed-off-by: Birk Skyum <birk.skyum@pm.me>
Signed-off-by: Birk Skyum <birk.skyum@pm.me>
Signed-off-by: Birk Skyum <birk.skyum@pm.me>
Signed-off-by: Birk Skyum <birk.skyum@pm.me>
Signed-off-by: Birk Skyum <birk.skyum@pm.me>
Signed-off-by: Birk Skyum <birk.skyum@pm.me>
Signed-off-by: Birk Skyum <birk.skyum@pm.me>
Signed-off-by: Birk Skyum <birk.skyum@pm.me>
Signed-off-by: Birk Skyum <birk.skyum@pm.me>
@ibgreen
Copy link
Collaborator

ibgreen commented Dec 18, 2023

Rebased. To ease the review have I reduce the number of changes in this PR, by bumping luma.gl separately (#2463), and reverting some changes caused by IDE auto-formatting.

@birkskyum Appreciated! @igorDykhta is trying to get some attention on the test failures so that we can land this asap, before we publish kepler.gl 3.0.

Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com>
@ibgreen ibgreen merged commit 09aee38 into keplergl:master Dec 19, 2023
7 checks passed
@igorDykhta
Copy link
Collaborator

@birkskyum Style previews are black for me

Screen Shot 2023-12-19 at 10 10 52 PM

@birkskyum
Copy link
Collaborator Author

birkskyum commented Dec 19, 2023

@birkskyum Style previews are black for me

Screen Shot 2023-12-19 at 10 10 52 PM

yes, in order to give a preview thumbnails have to be generated and linked. the mapbox style service had an endpoint with a thumbnail, so that is a bit different

@ibgreen
Copy link
Collaborator

ibgreen commented Dec 19, 2023

I have landed this to make sure it makes it as part of kepler.gl 3.0 release this Thursday. If possible please add any remaining polish in separate PRs asap.

@birkskyum
Copy link
Collaborator Author

birkskyum commented Dec 19, 2023

@ibgreen , The one existing thumbnail (NO_BASEMAP.png) is stored in this bucket:

https://studio-public-data.foursquare.com/statics/keplergl/geodude/NO_BASEMAP.png

I have generated thumbnails for the 6 new styles (400px X 300px). Is it possible to drop them there as well?

Thumbnails.zip

chrisgervang pushed a commit to chrisgervang/kepler.gl that referenced this pull request Dec 19, 2023
Signed-off-by: Chris Gervang <chris@gervang.com>
@igorDykhta
Copy link
Collaborator

@birkskyum
Copy link
Collaborator Author

@igorDykhta , thanks! there is a pr to apply them here:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MapLibre support
6 participants