heremaps / here-map-widget-for-jupyter Goto Github PK
View Code? Open in Web Editor NEWUse HERE Maps API for JavaScript in your Jupyter Notebook.
Home Page: https://here-map-widget-for-jupyter.readthedocs.io/en/latest/
License: MIT License
Use HERE Maps API for JavaScript in your Jupyter Notebook.
Home Page: https://here-map-widget-for-jupyter.readthedocs.io/en/latest/
License: MIT License
The Map
seems not to trigger a bounds
name change event like ipyleaflet does. I see a zoom
and center
one, but it would be much easier to not have to calculate the bounds from that.
After creating/showing a MapSettingsControl
it seems impossible to add layers to it such that they appear in the control. It would be nice to see that happen like in ipyleaflet.LeayersControl
.
import os
from here_map_widget import (Map, DefaultLayers, DefaultLayerNames,
GeoJSON, MapSettingsControl, ZoomControl)
api_key = os.getenv("HEREMAPS_API_KEY")
basemap = DefaultLayers(layer_name=DefaultLayerNames.raster.normal.map)
m = Map(center=[52.5, 13.4], zoom=10, basemap=basemap, api_key=api_key)
m.add_control(ZoomControl(alignment="LEFT_TOP"))
basemaps = [DefaultLayerNames.raster.normal.map, DefaultLayerNames.raster.normal.transit]
url = "https://raw.githubusercontent.com/johan/world.geo.json/master/countries.geo.json"
layers = [GeoJSON(url=url)]
layers = [{"label": "countries", "layer": GeoJSON(url=url)}]
msc = MapSettingsControl(basemaps=basemaps, layers=layers)
# does not add second layer
msc.layers.append({"label": "countries2", "layer": GeoJSON(url=url)})
m.add_control(msc)
# does not add second layer
msc.layers.append({"label": "countries2", "layer": GeoJSON(url=url)})
m
It seems one can install this package on Pyodide and hence JupyterLite using micropip, but the maps don't show, yet, indicating there is some issue with the JupyterLab extension. You can try on JupyterLite. Maybe worth giving a thought?
import micropip
await micropip.install(
"https://opencomputinglab.github.io/vce-wheelhouse/wheelhouse/"
"MarkupSafe-2.0.1-py2.py3-none-any.whl"
)
await micropip.install("here-map-widget-for-jupyter")
from here_map_widget import Map
api_key = "******"
m = Map(api_key=api_key, center=[52.51, 13.39], zoom=4)
m # gives: Loading widget...
Does the here map widget have a Layers Control, similar to the ipyleaflet Layers Control? I can't seem to find it on the API Reference.
https://ipyleaflet.readthedocs.io/en/latest/api_reference/layers_control.html
This widget definitely needs an update...
I can add controls and layers only with map.add_control()
and add_layer()
but I would also like to use +=
on the map as this shortens the code considerably when putting many things onto the map. In Ipyleaflet this is perfectly possible. It would be nice to have it here, too (no pun intended).
import os
from here_map_widget import Map, DefaultLayers, DefaultLayerNames, ZoomControl
api_key = os.getenv("HEREMAPS_API_KEY")
basemap = DefaultLayers(layer_name=DefaultLayerNames.raster.normal.map)
m = Map(center=[52, 13], zoom=6, basemap=basemap, api_key=api_key)
m.add_control(ZoomControl(alignment="LEFT_TOP")) # preferred: m += ZoomControl(...)
Thank you for developing this awesome package. I particularly like the 3D feature, which ipyleaflet is lacking.
Do you plan to support XYZ and WMS tile layers? I would love to incorporate this package into geemap if it can support XYZ and WMS tile layers. Thanks.
I want to display really big geometric shapes on the surface of a map, think boxes of arbitrary height using the extrusion
parameter of a Rectangle
, say. But in code like below, similar to this the rectangle is rendered only for values up to a maximum of 2047 (meters?). Above this number no rectangle is rendered.
The official documentation mentions map.Polygon.MAX_EXTRUDE_HEIGHT
, but it seems not to be supported in Python. Can it be set higher than 2047 and can it be exposed in Python?
import os
from here_map_widget import Bbox, Map, Rectangle
api_key = os.environ["LS_API_KEY"]
lon, lat = [50, 13]
m = Map(api_key=api_key, center=[lon, lat], zoom=8)
style = {"strokeColor": "#829", "lineWidth": 4}
bbox = Bbox(top=lon + 0.5, left=lat - 0.5, bottom=lon - 0.5, right=lat + 0.5)
rectangle = Rectangle(bbox=bbox, style=style, elevation=0, extrusion=2047)
m.add_object(rectangle)
m
This project currently requires ipywidgets <8. However, versions 8.0.0 - 8.0.2 are available.
This project requires branca <0.5. However, version 0.6 is available.
It looks like the layout for ipywidgets is not properly handled. I've seen this for buttons (should be square in the example below), but it might happen with other elements, too.
import os
from ipywidgets import Button, Layout
from here_map_widget import Map, DefaultLayers, DefaultLayerNames, WidgetControl
api_key = os.getenv("HEREMAPS_API_KEY")
basemap = DefaultLayers(layer_name=DefaultLayerNames.raster.normal.map)
m = Map(center=[52.5, 13.4], zoom=10, basemap=basemap, api_key=api_key)
layout = Layout(width="28px", height="28px")
btn = Button(icon="globe", layout=layout)
m.add_control(WidgetControl(widget=btn, alignment="LEFT_TOP"))
m
Widget should be supported to work on google colab
Maybe support the recently released Python 3.10 with according tests in GitHub actions. Just an idea.
It would be nice to have a transparent_bg
parameter for WidgetControls
like in ipyleaflet. ;)
Instructions
$ npm config set @here:registry https://repo.platform.here.com/artifactory/api/npm/here-node/
$ pip install here-map-widget-for-jupyter
$ jupyter nbextension install –py –sys-prefix here_map_widget
$ jupyter nbextension enable here_map_widget –py –sys-prefix
Code
from here_location_services import LS
from here_map_widget import Map, GeoJSON
ls = LS(api_key=my_key)
address = "Invalidenstr 116, 10115 Berlin, Germany"
gc_response = ls.geocode(query=address)
data = gc_response.to_geojson()
geo_layer = GeoJSON(data=data)
m = Map(api_key=my_key, center=[52.53086, 13.38469], zoom=12)
m.add_layer(geo_layer)
m
does not display map widget
Any outlook on the current status and further development is highly appreciated.
It looks like the Map
object bounds
are actually South, North, East, West
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.