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

[Bug] Raster style.json doesn't load #2570

Open
exrhizo opened this issue May 3, 2024 · 2 comments
Open

[Bug] Raster style.json doesn't load #2570

exrhizo opened this issue May 3, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@exrhizo
Copy link

exrhizo commented May 3, 2024

Describe the bug
My style json from mapbox docs doesn't load into the demo.

based my json on mapbox example

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://kepler.gl/demo
  2. Click to add a map style
  3. Add https://gist.githubusercontent.com/exrhizo/0c6250cb76ae92558a8a37f8caad9c2a/raw/4733d20447b4d8acec8a125bcd6c9022681a75e8/osm-raster-style.json
  4. Name it
  5. A preview tile shows up but "Add Style" is greyed out

Expected behavior
I can use a raster tile

Screenshots
image

Desktop (please complete the following information):

  • OS: Mac Senoma
  • Browser Chrome 124.0.6367.118 (Official Build) (arm64)
  • Version 3.0.0
@exrhizo exrhizo added the bug Something isn't working label May 3, 2024
@shge
Copy link

shge commented Jun 26, 2024

I found a way to add style (looks weird though):

  1. Enter mapbox://styles/mapbox/streets-v12
  2. Change something in URL
  3. Enter https://gist.githubusercontent.com/exrhizo/0c6250cb76ae92558a8a37f8caad9c2a/raw/4733d20447b4d8acec8a125bcd6c9022681a75e8/osm-raster-style.json
SS.2024-06-26.at.11.59.07.mov

@exrhizo
Copy link
Author

exrhizo commented Jun 27, 2024

🤯

I was able to get this to work programmatically:

export const BACKGROUND_LAYER_GROUP_SLUG = "Background";
export const BACKGROUND_LAYER_GROUP: DEFAULT_LAYER_GROUP = {
  slug: BACKGROUND_LAYER_GROUP_SLUG,
  filter: () => false,
  defaultVisibility: false,
  isVisibilityToggleAvailable: false,
  isMoveToTopAvailable: false,
  isColorPickerAvailable: true,
};

export function getOpenStreetMapStyles(): KeplerStyles {
  const osmStyleJsonUrl = `${window.location.origin}/app/static/kepler/osm-raster-style.json`;
  const style: KeplerStyles = {
    osm_public: {
      id: "osm_public",
      label: "Open Street Map",
      url: "",
      icon: "https://a.tile.openstreetmap.org/0/0/0.png",
      layerGroups: [BACKGROUND_LAYER_GROUP],
      colorMode: "LIGHT",
      style: {
        version: 8,
        name: "Open Street Map",
        sources: {
          openmaptiles: {
            type: "raster",
            tiles: [
              "https://a.tile.openstreetmap.org/{z}/{x}/{y}.png",
              "https://b.tile.openstreetmap.org/{z}/{x}/{y}.png",
              "https://c.tile.openstreetmap.org/{z}/{x}/{y}.png",
            ],
            tileSize: 256,
            attribution:
              '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
          },
        },
        layers: [
          {
            id: "simple-tiles",
            type: "raster",
            source: "openmaptiles",
            minzoom: 0,
            maxzoom: 19,
          },
        ],
      },
    },
  };

  console.log("Kepler.App Using Open Street Map", { osmStyleJsonUrl, style });
  return style;
}

mapStyles = getOpenStreetMapStyles();
keplerGlReducer.initialState({
    mapStyle: {
      mapStyles,
      styleType,
}, ... })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants