Git Product home page Git Product logo

opengeos / mapwidget Goto Github PK

View Code? Open in Web Editor NEW
214.0 9.0 12.0 1.11 MB

Custom Jupyter widgets for creating interactive 2D/3D maps using popular JavaScript libraries with bidirectional communication, such as Cesium, Mapbox, MapLibre, Leaflet, and OpenLayers

Home Page: http://mapwidget.gishub.org

License: MIT License

Python 69.26% JavaScript 29.04% CSS 0.96% Dockerfile 0.74%
geopython geospatial ipywidgets jupyter mapping python anywidget cesium leaflet mapbox

mapwidget's Introduction

Welcome to mapwidget

image image image image image

Custom Jupyter widgets for creating interactive maps using JavaScript libraries with bidirectional communication

The mapwidget package provides a set of custom map widgets for creating interactive maps in a Jupyter environment using different JavaScript mapping libraries, such as Cesium, Leaflet, Mapbox, MapLibre, and OpenLayers. The widgets are built on top of the anywidget Python package.

Examples

Demos

Cesium

Mapbox

MapLibre

Credits

This package was created with Cookiecutter and the giswqs/pypackage project template.

mapwidget's People

Contributors

giswqs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mapwidget's Issues

Cesium token doesn't work

I am using Anaconda (Python3.7) on Windows and mapwidget 0.1.2. I can use it with Mapbox but with CESIUM I get the following error: TraitError: The 'token' trait of a Map instance expected a unicode string, not the NoneType None.

I basically followed your tutorial and set os.environ['CESIUM_TOKEN'] to my newly generated token.

With Cesium I have a KeyError

With

m = mapwidget.Map(center=[37.655, -122.4175], altitude=400, height='600px')
m

The result is :

KeyError Traceback (most recent call last)

/usr/local/lib/python3.9/dist-packages/traitlets/traitlets.py in get(self, obj, cls)
652 try:
--> 653 value = obj._trait_values[self.name]
654 except KeyError:

KeyError: 'token'

During handling of the above exception, another exception occurred:

TraitError Traceback (most recent call last)

9 frames

/usr/local/lib/python3.9/dist-packages/traitlets/traitlets.py in error(self, obj, value, error, info)
839 describe("the", value),
840 )
--> 841 raise TraitError(e)
842
843 def get_metadata(self, key, default=None):

TraitError: The 'token' trait of a Map instance expected a unicode string, not the NoneType None.

Panel not working with mapwidget.cesium: Class null not found in module @jupyter-widgets/[email protected] #88

It is unclear to me which package is responsible for this error. So I've crossposted to

Environment Information

  • mapwidget version: 0.1.2
  • Python version: 3.9
  • Operating System: Windows

Description

I would like to use Panel with mapwidget.cesium. Panel works with (some) ipywidgets via ipywidgets-bokeh.

Exception

Class null not found in module @jupyter-widgets/[email protected]      ipywidgets_bokeh.js?v=59296d23d623ce0adf7675d22156e83b1248c8508135a65dd8a9e38c497e94a8:8 

image

Reproducible Example

pip install panel==0.14.1 ipywidgets-bokeh==1.3.0 mapwidget==0.1.2

Other versions: ipywidgets-8.0.5 jupyterlab-widgets-3.0.6 widgetsnbextension-4.0.6 anywidget-0.2.0

mapwidget_app.py

import os
import mapwidget.cesium as mapwidget
import panel as pn

pn.extension("ipywidgets")

try:
    token = os.environ['CESIUM_TOKEN']
except KeyError as ex:
    raise EnvironmentError(
        "CESIUM_TOKEN environment variable not set. "
        "Sign up for free and get a free Cesium token here https://ion.cesium.com/signup/"
        ) from ex

cesium_map = mapwidget.Map(center=[40.70605, -74.01177], altitude=600, height='600px', token=token)
pn.panel(cesium_map).servable()
panel serve mapwidget_app.py

Open: http://localhost:5006/mapwidget_app and see the exception in the browsers console.

Add PMTiles support to MapLibre

Is there a way to support adding PMTiles to MapWidget MapLibre maps?

PMTiles are an open-source solution for single-file archive format for tiled data:

A PMTiles archive can be hosted on a commodity storage platform such as S3, and enables low-cost, zero-maintenance map applications that are "serverless" - free of a custom tile backend or third party provider.

See https://github.com/protomaps/PMTiles and https://protomaps.com/docs/pmtiles

For use in MapLibre, it apparently needs an additional JS plugin (see https://protomaps.com/docs/frontends/maplibre -- "For reading PMTiles directly from cloud storage, you'll need the pmtiles JavaScript library."

Receive "Error displaying widget"

Environment Information

  • mapwidget version: "^0.1.2"
  • Python version: 3.10.12
  • Operating System: macOS Version 13.5 (22G74) (on M1), Firefox 116.0.3 (64-bit)

Description

On repeating basic Leaflet map example (https://mapwidget.gishub.org/examples/leaflet/)
I receive a 'Error displaying widget' after attempting to display map

What I Did

On inspection of the Web Console, errors are populated regarding Error: Could not create a view for model id, or TypeError: class constructors must be invoked with 'new'
See screenshot:

image

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.