GithubHelp home page GithubHelp logo

Cannot execute example code about dash-deck HOT 1 CLOSED

plotly avatar plotly commented on June 27, 2024
Cannot execute example code

from dash-deck.

Comments (1)

KS-HTK avatar KS-HTK commented on June 27, 2024 1

As to why you are not seeing a map. Add map_provider="mapbox" to pdk.Deck. Default map provider is carto and they do not seem to support map_style.SATELLITE. Look here for supported styles of carto.

r = pdk.Deck(
    bitmap_layer,
    initial_view_state=view_state,
    map_provider="mapbox",
    map_style=pdk.map_styles.SATELLITE,
)

For me the bitmap won't load due to a 403 Forbidden from imgur. Not sure why as loading the URL directly works fine. Possibly just an issue with using imgur.

Using the example from deck.gl documentation works fine for me. They use this URL: https://raw.githubusercontent.com/visgl/deck.gl-data/master/website/sf-districts.png

You should not need to double Quote the URL either.
Here is the version I got running:

import os
import dash
import dash_deck
from dash import html
import pydeck as pdk

mapbox_api_token =  os.getenv("MAPBOX_ACCESS_TOKEN")

app = dash.Dash(__name__)

# Map of San Francisco from 1906
IMG_URL = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/website/sf-districts.png'

# Specifies the corners of the image bounding box
BOUNDS = [-122.5190, 37.7045, -122.355, 37.829]

bitmap_layer = pdk.Layer(
    "BitmapLayer", image=IMG_URL, bounds=BOUNDS, opacity=0.7
)

view_state = pdk.ViewState(
    latitude=37.7576171, longitude=-122.5776844, zoom=10, bearing=-45, pitch=60,
)

r = pdk.Deck(
    bitmap_layer,
    initial_view_state=view_state,
    map_provider="mapbox",
    map_style=pdk.map_styles.SATELLITE,
)


app.layout = html.Div(
    dash_deck.DeckGL(r.to_json(), id="deck-gl", mapboxKey=mapbox_api_token)
)

if __name__ == "__main__":
    app.run_server(debug=False)

from dash-deck.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.