-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add(pydeck) support for deck.gl widgets (#9342)
* add(pydeck) support for deck.gl widgets
- Loading branch information
1 parent
2ba7157
commit 294b6f3
Showing
10 changed files
with
76 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Widget | ||
====== | ||
|
||
.. automodule:: pydeck.bindings.widget | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from .json_tools import JSONMixin | ||
|
||
TYPE_IDENTIFIER = "@@type" | ||
|
||
|
||
class Widget(JSONMixin): | ||
""" | ||
Represents a deck.gl widget, which are UI components around the WebGL2/WebGPU canvas | ||
to offer controls and information for a better user experience. | ||
Parameters | ||
--------- | ||
type : str, default None | ||
deck.gl widget to display, e.g., 'CompassWidget' | ||
id : str, default None | ||
Unique name for widget | ||
placement : string, default 'top-left' | ||
Placement of the widget on the map. Options are 'top-left', 'top-right', 'bottom-left', 'bottom-right', and 'fill'. | ||
Note that not all widgets support custom placement. | ||
view_id : string, default None | ||
ID of the view to which the widget should be added. The widget will be added to the default view if not specified. | ||
Note that not all widgets support custom view_id. | ||
**kwargs | ||
Any of the parameters passable to a deck.gl Widget | ||
""" | ||
|
||
def __init__(self, type, id=None, placement=None, view_id=None, **kwargs): | ||
self.type = type | ||
self.id = id | ||
self.placement = placement | ||
self.view_id = view_id | ||
self.__dict__.update(kwargs) | ||
|
||
@property | ||
def type(self): | ||
return getattr(self, TYPE_IDENTIFIER) | ||
|
||
@type.setter | ||
def type(self, type_name): | ||
self.__setattr__(TYPE_IDENTIFIER, type_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import json | ||
|
||
from pydeck import Widget | ||
|
||
|
||
def test_widget_constructor(): | ||
EXPECTED = {"@@type": "ZoomWidget", "placement": "top-right"} | ||
assert json.loads(Widget(type="ZoomWidget", placement="top-right", view_id=None).to_json()) == EXPECTED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters