Advertisement
aristotle029

Untitled

Jun 20th, 2024
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.83 KB | None | 0 0
  1. import pydeck as pdk
  2.  
  3. # Sample data URL
  4. DATA_URL = "https://raw.githubusercontent.com/visgl/deck.gl-data/master/website/sf-bike-parking.json"
  5.  
  6. # Define a hexagon layer with tooltips enabled
  7. hexagon_layer = pdk.Layer(
  8.     "HexagonLayer",
  9.     data=DATA_URL,
  10.     get_position='[lng, lat]',
  11.     radius=200,
  12.     elevation_scale=4,
  13.     elevation_range=[0, 1000],
  14.     pickable=True,  # Enables picking
  15.     extruded=True,
  16. )
  17.  
  18. # Define the initial view state
  19. view_state = pdk.ViewState(
  20.     longitude=-122.4,
  21.     latitude=37.75,
  22.     zoom=11,
  23.     pitch=50,
  24. )
  25.  
  26. # Define the tooltip
  27. tooltip = {"html": "<b>Elevation Value:</b> {elevationValue}", "style": {"color": "white"}}
  28.  
  29. # Render the deck.gl map with the tooltip
  30. r = pdk.Deck(
  31.     layers=[hexagon_layer],
  32.     initial_view_state=view_state,
  33.     tooltip=tooltip
  34. )
  35. r.show()
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement