jupyter-widgets / ipyleaflet Goto Github PK
View Code? Open in Web Editor NEWA Jupyter - Leaflet.js bridge
Home Page: https://ipyleaflet.readthedocs.io
License: MIT License
A Jupyter - Leaflet.js bridge
Home Page: https://ipyleaflet.readthedocs.io
License: MIT License
In JupyterLab, after clicking "Create New View for Cell" on an ipyleaflet map, the new view seems to have a different center coordinates, and tiles fail to appear.
Note that the tile(s) shown in the upper left of the new view map are the same ones shown in the lower right of the original map cell. i.e. the missing tiles would be visible in the new map view if the center coordinates were correct.
My current setup:
jupyter_core.version = 4.4.0
jupyter_client.version = 5.1.0
jupyterlab.version = 0.29.1
jupyterlab_launcher.version = 0.5.5
ipyleaflet.version = 0.5.1
I get this error when bulding jupyterlab on windows, not sure what to do about it.
For now, I'll remove ipyleaflet-1.0.0b3. Is there another suggestion ?
C:\winpython-64bit-3.6.x.0\scripts>jupyter labextension list
JupyterLab v0.31.0rc1
Known labextensions:
app dir: C:\winpython-64bit-3.6.x.0\python-3.6.4.amd64\share\jupyter\lab
bqplot
bqplot v0.3.2 enabled ok
jupyter-leaflet
jupyter-leaflet v0.5.1 enabled ok
jupyter-matplotlib
jupyter-matplotlib v0.3.0 enabled ok
jupyter-threejs
jupyter-threejs v0.4.1 enabled ok
C:\winpython-64bit-3.6.x.0\scripts>jupyter lab clean
C:\winpython-64bit-3.6.x.0\scripts>"%WINPYDIR%\Scripts\jupyter.exe" labextension install bqplot
> C:\winpython-64bit-3.6.x.0\python-3.6.4.amd64\..\tools\n\npm.CMD pack bqplot
bqplot-0.3.2.tgz
> node C:\winpython-64bit-3.6.x.0\python-3.6.4.amd64\lib\site-packages\jupyterlab\staging\yarn.js install
yarn install v1.3.2
[1/4] Resolving packages...
[2/4] Fetching packages...
info [email protected]: The platform "win32" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "@jupyterlab/json-extension > [email protected]" has unmet peer dependency "react@^0.14.0 || ^15.0.0 || ^16.0.0".
warning "@jupyterlab/json-extension > [email protected]" has unmet peer dependency "react@^15.0.0".
warning "@jupyterlab/json-extension > [email protected]" has unmet peer dependency "react-dom@^15.0.0".
warning "@jupyterlab/vdom-extension > @nteract/[email protected]" has unmet peer dependency "react@^15.6.1".
[4/4] Building fresh packages...
[-/3] ⠈ waiting...
[2/3] ⠈ canvas: not ok
[3/3] ⠈ jupyter-matplotlib
[-/3] ⠈ waiting...
warning Error running install script for optional dependency: "C:\\WinPython\\basedir36\\buildQt5\\winpython-64bit-3.6.x.0\\python-3.6.4.amd64\\share\\jupyter\\lab\\staging\\node_modules\\canvas: Command failed.\nExit code: 1\nCommand: node-gyp rebuild\nArguments: \nDirectory: C:\\WinPython\\basedir36\\buildQt5\\winpython-64bit-3.6.x.0\\python-3.6.4.amd64\\share\\jupyter\\lab\\staging\\node_modules\\canvas\nOutput:\nC:\\WinPython\\basedir36\\buildQt5\\winpython-64bit-3.6.x.0\\python-3.6.4.amd64\\share\\jupyter\\lab\\staging\\node_modules\\canvas>if not defined npm_config_node_gyp (node \"C:\\WinPython\\basedir36\\buildQt5\\winpython-64bit-3.6.x.0\\tools\\n\\node_modules\\npm\\bin\\node-gyp-bin\\\\..\\..\\node_modules\\node-gyp\\bin\\node-gyp.js\" rebuild ) else (node \"\" rebuild ) \r\ngyp info it worked if it ends with ok\ngyp info using [email protected]\ngyp info using [email protected] | win32 | x64\ngyp ERR! configure error \ngyp ERR! stack Error: Python executable \"C:\\WinPython\\basedir36\\buildQt5\\winpython-64bit-3.6.x.0\\python-3.6.4.amd64\\python.EXE\" is v3.6.4, which is not supported by gyp.\ngyp ERR! stack You can pass the --python switch to point to Python >= v2.5.0 & < 3.0.0.\ngyp ERR! stack at failPythonVersion (C:\\WinPython\\basedir36\\buildQt5\\winpython-64bit-3.6.x.0\\tools\\n\\node_modules\\npm\\node_modules\\node-gyp\\lib\\configure.js:454:14)\ngyp ERR! stack at C:\\WinPython\\basedir36\\buildQt5\\winpython-64bit-3.6.x.0\\tools\\n\\node_modules\\npm\\node_modules\\node-gyp\\lib\\configure.js:443:9\ngyp ERR! stack at ChildProcess.exithandler (child_process.js:189:7)\ngyp ERR! stack at emitTwo (events.js:106:13)\ngyp ERR! stack at ChildProcess.emit (events.js:191:7)\ngyp ERR! stack at maybeClose (internal/child_process.js:920:16)\ngyp ERR! stack at Socket.<anonymous> (internal/child_process.js:351:11)\ngyp ERR! stack at emitOne (events.js:96:13)\ngyp ERR! stack at Socket.emit (events.js:188:7)\ngyp ERR! stack at Pipe._handle.close [as _onclose] (net.js:497:12)\ngyp ERR! System Windows_NT 10.0.16299\ngyp ERR! command \"C:\\\\WinPython\\\\basedir36\\\\buildQt5\\\\winpython-64bit-3.6.x.0\\\\python-3.6.4.amd64\\\\..\\\\tools\\\\n\\\\node.exe\" \"C:\\\\WinPython\\\\basedir36\\\\buildQt5\\\\winpython-64bit-3.6.x.0\\\\tools\\\\n\\\\node_modules\\\\npm\\\\node_modules\\\\node-gyp\\\\bin\\\\node-gyp.js\" \"rebuildsuccess Saved lockfile.
Done in 489.24s.
> node C:\winpython-64bit-3.6.x.0\python-3.6.4.amd64\lib\site-packages\jupyterlab\staging\yarn.js run build:prod
yarn run v1.3.2
$ webpack -p
Hash: 103b2a5117d8f0c79262
Version: webpack 2.7.0
Time: 110468ms
Asset Size Chunks Chunk Names
912ec66d7572ff821749319396470bde.svg 444 kB [emitted] [big]
2273e3d8ad9264b7daa5bdbf8e6b47f8.png 1.47 kB [emitted]
6a1e950d14904d4b6fb5c9bdc3dfad06.png 3.58 kB [emitted]
deac1d4aa2ccf7ed832e4db55bb64e63.png 1.91 kB [emitted]
4f0283c6ce28e888000e978e537a6a56.png 1.26 kB [emitted]
a6137456ed160d7606981aa57c559898.png 696 bytes [emitted]
d95d69fa8a7dfe391399e22c0c45e203.png 2.59 kB [emitted]
44a526eed258222515aa21eaffd14a96.png 618 bytes [emitted]
af7ae505a9eed503f8b8e6982036873e.woff2 77.2 kB [emitted]
fee66e712a8a08eef5805a46892932ad.woff 98 kB [emitted]
b06871f281fee6b241d60582ae9369b9.ttf 166 kB [emitted]
674f50d287a8c48dc19ba404d20fe713.eot 166 kB [emitted]
0.01bbce03dfb038fb4095.js 425 kB 0 [emitted] [big] vega2
1.697f116e8467e0f2ccc6.js 422 kB 1 [emitted] [big]
main.a9060117c02afbdfe1f6.js 7.02 MB 2 [emitted] [big] main
vendor.8111c5f9148384d98efc.js 1.48 MB 3 [emitted] [big] vendor
manifest.d65e71dddccce81a5785.js 1.57 kB 4 [emitted] manifest
0.01bbce03dfb038fb4095.js.map 439 kB 0 [emitted] vega2
1.697f116e8467e0f2ccc6.js.map 452 kB 1 [emitted]
main.a9060117c02afbdfe1f6.js.map 8.59 MB 2 [emitted] main
vendor.8111c5f9148384d98efc.js.map 1.53 MB 3 [emitted] vendor
manifest.d65e71dddccce81a5785.js.map 1.78 kB 4 [emitted] manifest
index.html 1.71 kB [emitted]
[+HaM] ./~/@phosphor/messaging/lib/index.js 18.5 kB {3} [built]
[2Kj9] ./~/@phosphor/widgets/lib/index.js 1.34 kB {3} [built]
[8U58] ./~/codemirror/lib/codemirror.js 352 kB {3} [built]
[CUbq] ./~/@phosphor/signaling/lib/index.js 18.1 kB {3} [built]
[GiK3] ./~/react/index.js 190 bytes {3} [built]
[O27J] ./~/react-dom/index.js 1.36 kB {3} [built]
[Vszx] ./~/@phosphor/domutils/lib/index.js 636 bytes {3} [built]
[cYMN] ./~/@phosphor/virtualdom/lib/index.js 21 kB {3} [built]
[lMhA] ./~/@phosphor/dragdrop/lib/index.js 33.7 kB {3} [built]
[nh00] ./~/@phosphor/disposable/lib/index.js 4.24 kB {3} [built]
[qzHn] ./~/@phosphor/coreutils/lib/index.js 721 bytes {3} [built]
[ug+F] ./~/xterm/lib/xterm.js 52.7 kB {3} [built]
[5] multi @phosphor/algorithm @phosphor/application @phosphor/commands @phosphor/coreutils @phosphor/datagrid @phosphor/disposable @phosphor/domutils @phosphor/dragdrop @phosphor/messaging @phosphor/properties @phosphor/signaling @phosphor/virtualdom @phosphor/widgets ajv ansi_up codemirror comment-json es6-promise marked moment path-posix react react-dom sanitize-html url-parse xterm 328 bytes {3} [built]
[6] multi whatwg-fetch ./build/index.out.js 40 bytes {2} [built]
[wr2+] ./~/@phosphor/properties/lib/index.js 6.58 kB {3} [built]
+ 1618 hidden modules
ERROR in main.a9060117c02afbdfe1f6.js from UglifyJs
Unexpected token: punc (,) [./~/jupyter-leaflet/src/jupyter-leaflet.js:528,30][main.a9060117c02afbdfe1f6.js:117674,32]
Child html-webpack-plugin for "index.html":
[3IRH] (webpack)/buildin/module.js 517 bytes {0} [built]
[DuR2] (webpack)/buildin/global.js 509 bytes {0} [built]
[GTAU] ./~/html-loader!./templates/partial.html 401 bytes {0} [built]
[M4fF] ./~/lodash/lodash.js 540 kB {0} [built]
[vxCX] ./~/html-webpack-plugin/lib/loader.js!./templates/template.html 1.6 kB {0} [built]
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
C:\winpython-64bit-3.6.x.0\scripts>
Hi,
it looks like the style attribut is always needed for GeoJSON, also for adding markers.
So for adding markers, you have to do somethin like
layer = GeoJSON(data=markers, style={'fillColor': 'blue'})
map.add_layer(layer)
although fillColor has no effect on markers.
If I only use
layer = GeoJSON(data=markers)
map.add_layer(layer)
it doesn't show the markers on the map. Or did I missed something?
It would be nice, if you could use GeoJSON also without the style attribut.
m = Map(center = [34.62, -77.34])
m.bounds
gives:
'Map' object has no attribute 'bounds'
This is happening, for instance, in examples/Primitives.ipynb
Thanks for the awesomely useful and fun package :)
Trying to load a jpg
image in ipyleaflet
using ImageOverlay
I got different behaviour between the standard notebook interface and jupyterlab.
The following code work in a standard notebook but fail to render the image (404 error) in jupyterlab.
from ipyleaflet import (
Map, ImageOverlay, TileLayer
)
m = Map(default_tiles=TileLayer(opacity=1.0), center=meta['C'], zoom=12)
meta = {'C': (41.066192631345636, -68.91168330924846),
'LL': (41.06314714201035, -68.93226141787825),
'UR': (41.06923444219005, -68.89110330910114),
'proj': '+proj=utm +zone=19 +datum=WGS84 +units=m +no_defs ',
'raster': 'test.jpg'}
layer = ImageOverlay(url=meta['raster'],
bounds=(meta['LL'], meta['UR']))
m.add_layer(layer)
This notebook may help to reproduce the issue.
If using a an url pointing to a fileonline, in jupyterlab, the image is rendered correctly.
When I download my notebooks as html the leaflet outputs are always gone, same with downloading the notebook as ipynb or pdf
I'm under Mac OSX 10.10.5 and using python from macports.
I cannot get ipyleaflet
works in a virtualenv created using the --system-site-packages
keyword.
I suppose it is because the system jupyter-s
subcommands search in their installation path and not in the one from virtualenv
.
I'm not entirely sure if it is an issue to be open here or at Issues · ipython-contrib/IPython-notebook-extensions, maybe I'll open another one there.
Here the details:
Those are the version of jupyter-s
stuff I'm using. (the pyXX prefix is used by macport to differenziate versions of the same command).
py27-ipywidgets @5.1.4_0 (active)
py27-widgetsnbextension @1.2.2_0 (active)
py27-widgetsnbextension @1.2.2_0 (active)
py27-jupyter @1.0.0_1 (active)
py27-jupyter_client @4.2.2_0 (active)
py27-jupyter_console @4.1.1_0 (active)
py27-jupyter_core @4.1.0_0 (active)
If I install ipyleaflet
in a virtual env and activate it, I get
jupyter nbextension enable --py ipyleaflet
Traceback (most recent call last):
File "/opt/local/bin/jupyter-nbextension", line 9, in <module>
load_entry_point('notebook==4.2.0', 'console_scripts', 'jupyter-nbextension')()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/jupyter_core/application.py", line 267, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/traitlets/config/application.py", line 596, in launch_instance
app.start()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/notebook/nbextensions.py", line 952, in start
super(NBExtensionApp, self).start()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/jupyter_core/application.py", line 256, in start
self.subapp.start()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/notebook/nbextensions.py", line 860, in start
self.toggle_nbextension_python(self.extra_args[0])
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/notebook/nbextensions.py", line 836, in toggle_nbextension_python
logger=self.log)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/notebook/nbextensions.py", line 459, in enable_nbextension_python
logger=logger)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/notebook/nbextensions.py", line 374, in _set_nbextension_state_python
m, nbexts = _get_nbextension_metadata(module)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/notebook/nbextensions.py", line 1114, in _get_nbextension_metadata
m = import_item(module)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/traitlets/utils/importstring.py", line 41, in import_item
return __import__(parts[0])
ImportError: No module named ipyleaflet
and jupyter-nbextension list
gives
Known nbextensions:
config dir: /Users/kidpixo/.jupyter/nbconfig
notebook section
jupyter-js-widgets/extension enabled
- Validating: OK
ipyleaflet enabled
- Validating: problems found:
- require? X ipyleaflet
If I install ipyleaflet
globally everything is fine.
jupyter-nbextension list
Known nbextensions:
config dir: /Users/kidpixo/.jupyter/nbconfig
notebook section
jupyter-leaflet/extension enabled
- Validating: OK
jupyter-js-widgets/extension enabled
- Validating: OK
ipyleaflet disabled
I'm still wondering why I have jupyter-leaflet/extension
and ipyleaflet
in my extensions...
I wanted to use LayerGroup() to create a layer of markers, however I can't get it to render on the map.
After extensive reading of the python and java script to understand how this might be done, my code looks like this.
center = [-33.858840, 151.206701]
zoom = 0
map_nsw = ll.Map(default_tiles=ll.TileLayer(opacity=1.0),
center=center, zoom=zoom)
lg = ll.LayerGroup()
mark = ll.Marker(location=center)
c = ll.Circle(location=center)
lg.layers = [mark, c]
map_nsw += lg
map_nsw
What have I missed or isn't LayerGroup implemented.
I installed the widget flling the readme instructions, i added the lines for off line rendering as well.
When i try to run the examples no widget is displayed. In the JS console i've this log :
https://gist.github.com/fafd6b389d99d9252470
this the lines of code is used in the notebook :
http://nbviewer.ipython.org/gist/epifanio/a96da4fde5c53755e562
my ipython version is (3, 1, 0, 'dev') running in Jupyter, built before the big split.
python 3.4.3
Apparently, none of the style parameters for CircleMarker shown in the primitives example are working
When I run:
m = Map(center=[34.6252978589571, -77.34580993652344], zoom=10)
mark = CircleMarker(location=m.center, radius=5, color="#000000", fill_color="#ff0000")
m.add_layer(mark)
m
the marker doesn't change the default radius, color and fill color.
These parameters do work when plotting Circle instead of CircleMarker, though.
Am I missing something?
When config args are passed to the classes they're not getting synced on the JS side (IIUC). This can be worked around by constructing the class first then setting the attributes afterwards.
I believe this is the underlying reason for #51 (though there must be something else going on if Circle
does work).
Is it possible to add a caption or a legend to the map
(for instance to indicate marker meaning)
Thanks,
Loic
I have been tracking ipywidgets evolution, which are supposed to work with the evolving jupyter lab. Figuring that ipyleaflet is exemplary - I have learned some tricks by studying your code -- I just tried to open GeoJSON.ipynb in jupyter lab, after establishing that, as expected, it runs fine in the classic jupyter notebook.
I get this error:
Widget Javascript not detected. It may not be installed or enabled properly.
accompanied by no other error messages or diagnostics. Have you had any luck with yourwidget in the latest jupyter lab?
None of my own widgets, all of which are working fine in the classic notebook, work in lab. Emulating ipyleaflet might help me figure out what I need to do.
Thanks!
When installing and using this package with jupyter
using the instructions from the README, I initially get the following error on OSX and Ubuntu (with fresh installations):
Widget Javascript not detected. It may not be installed properly. Did you enable the widgetsnbextension? If not, then run "jupyter nbextension enable --py --sys-prefix widgetsnbextension"
Performing the extra step of running:
jupyter nbextension enable --py widgetsnbextension
seems to fix the problem. I'm guessing that this is a dependency of ipyleaflet
that needs similar registration the first time it is installed. Perhaps it could be mentioned in the docs for new users?
I upgraded to 0.5.3, and Marker
is working, but not MarkerCluster
. I just get a blank map.
The Proj4Leaflet Javascript library adds support for additional projections in Leaflet, beyond the standard projections. Could this also be added to IPyLeaflet so that non-standard projections could be requested? For example:
map = ipyleafletee.Map(
crs='EPSG:3020', # http://spatialreference.org/ref/epsg/wgs-84-antarctic-polar-stereographic/
zoom=6,
center=[0, 0],
default_tiles=ipyleaflet.TileLayer(url=SOME_URL_THAT_RETURNS_PROJECTED_TILES)
)
map
When I execute this script in a jupyter cell, the two points are shown but not the line between them. I checked this against an online GeoJSON viewer. Would be very happy if anybody could check this.
from ipyleaflet import Map, GeoJSON
m = Map(
center=[51.5, 10],
zoom=6,
)
g = GeoJSON(
data={
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [7.63, 52.36]
},
"properties": {}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [8.63, 52.36]
},
"properties": {}
},
{
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[7.63, 52.36], [8.63, 52.36]
]
},
"properties": {}
}
]
}
)
m.add_layer(g)
m
Library versions:
Hi,
there exist a Bing plugin for leaflet, that allows you to use the Bing Mapping Javascript API.
At the moment, ipyleaflet (with the example provided), only provide as TileLayer an Openstreetmap one.
Is there a way to use other tilelayers via ipyleaflet ?
I would like to improve support for popup. I have seen that for popup you can create them but not much more. Can someone clarify what the initial intent was - and the foreseen associated syntax?
I'm trying to use some tiles I generated with custom maps.
I already implemented a pure leaflet test Leaflet Map Test and I was really excited to get all this in notebooks!
The biggest problem is that the ipyleaflet.leaflet.TileLayer
cannot change all the parameter leaflet.tilelayer
(here) would accept.
In particular, the tms
and zoomOffset
are critical to my application , I manages to hack the parameter directly in the js code from jupyter-leaflet on my machine.
Would be hard to implement this in ipyleaflet? In the js code the parameter are there, but commented out.
I haven't enough knowledge of the jupyter widget mechanism and javascript to make this change.
Adding the tms=true
paramter to ipyleaflet.leaflet.TileLayer
inizialization doesn't affect the instantiated object, I guess while the class TileLayer(RasterLayer)
in leaflet.py doesn't have this parameter declared and cannot pass it further.
Hi,
I'm trying to display a jpeg image as ImageOverlay:
This example should reproduce the issue I'm having:
the following lines, In a notebook code cell, are working fine:
import os
import tempfile
from ipyleaflet import (
Map,
TileLayer, ImageOverlay,
)
!rm -rf bathy.jpg
!wget http://epinux.com/bathy.jpg
filename = 'bathy.jpg'
m = Map(default_tiles=TileLayer(opacity=1.0), center=(41.066, -68.911), zoom=15)
layer = ImageOverlay(url=filename, bounds=((41.06310460951131, -68.93158620445642),
(41.0693891696277, -68.89121107400065)))
m.add_layer(layer)
m
While if I use a tempfile
directory and store the png in it, the widget doesn't render the image (perhaps becouse of wrong permison)
tmpdir = tempfile.mkdtemp()
!rm -rf bathy.jpg
!wget http://epinux.com/bathy.jpg
filename = 'bathy.jpg'
!mv {filename} {tmpdir}/
filename = os.path.join(tmpdir, filename)
m = Map(default_tiles=TileLayer(opacity=1.0), center=(41.066, -68.911), zoom=15)
layer = ImageOverlay(url=filename, bounds=((41.06310460951131, -68.93158620445642),
(41.0693891696277, -68.89121107400065)))
m.add_layer(layer)
m
While testing with the IPython.core.displa
Image rendering:
from IPython.core.display import Image
Image(filename)
this works fine.
How can I use ImageOverlay to render temporary files generated withing then notebook using the tempfile
module?
the repo name is wrong :)
HI,
There's a number of leaflet plugins we'd like to get access to in ipyleaflet. What's the workflow to extend ipyleaflet to more plugins? thanks
Displaying basic maps works fine with the update to ipywidgets 7.0, but additional layers are not being displayed.
Just playing around with ipyleaflet
- it's a neat project! I wasn't a big fan of the default OpenStreetMap tiles (too busy) so I figured out how to use MapBox tiles.
In case it's of use for anyone else I've documented how to do so below. Since this isn't a real issue per-se feel free to close...
The underlying leaflet.js library is provider agnostic and can be used with almost any tile provider. A preview of freely available tile providers is available at http://leaflet-extras.github.io/leaflet-providers/preview/.
MapBox is a tile provider which has a free plan which requires signing up to get an access token. To use MapBox (as with any other provider) you simply provide the correct url to the TileLayer
constructor - e.g.
url = "https://api.mapbox.com/v4/mapbox.outdoors/{z}/{x}/{y}.png?access_token=%s" % os.environ['MAPBOX_API_TOKEN']
provider = TileLayer(url=url, opacity=1)
m = Map(default_tiles=provider, center=(-27.4698, 153.0251), zoom=5)
m.layout.height = '800px'
m
I tried out the new MarkerCluster capability in 0.5.3, and it works great in my notebook here:
https://gist.github.com/anonymous/d414d59e50e57e23436adba70fd48b35
but I'm struggling a bit with the interaction. [BTW, this notebook should run anywhere, as it uses only web services to aquire data]
I was originally plotting markers using geoJSON, and the interaction I'm looking for is to return the name of the marker to python when I click on it. In cell [13], with geoJSON, I use feature_layer.on_click
to specifying printing the name of the marker below the plot. This works great:
I would like to do the same in cell [15], using MarkerCluster
, but I cannot figure out how to get the name of the marker back on click:
There is no feature_layer.on_click
for MarkerCluster
, and I guess that make sense since I really just need interaction with the individual Marker
objects, right?
But the Marker
objects don't seem to have on_click
either. Would it be on_trait_change
?
If I want to use the Draw control with a prepopulated editable layer, this is currently not possible (prepopulated constant layers are possible).
When I go to http://mybinder.org/repo/ellisonbg/ipyleaflet/notebooks/examples, I'm prompted to enter a password or token. What should I enter to use the notebooks on mybinder?
It would be great if ipyleaflet supported marker styling.
Perhaps the same GeoJSON conventions as GitHub: https://help.github.com/articles/mapping-geojson-files-on-github/ ?
This would allow Ipyleaflet users to easily change marker colors and styles, fixing problems like reproducible-notebooks/ERDDAP_timeseries_explorer#3.
Simple example:
https://github.com/rsignell-usgs/dc-wifi-social/blob/master/bars.geojson
On GitHUB this GeoJSON produces a map that looks like this:
While the same GeoJSON in Ipyleaflet:
import urllib.request
import json
url = 'https://raw.githubusercontent.com/rsignell-usgs/dc-wifi-social/master/bars.geojson'
req = urllib.request.Request(url)
r = urllib.request.urlopen(req).read()
data = json.loads(r.decode('utf-8'))
center = [38.9, -77.05]
zoom = 12
map = ipyl.Map(center=center, zoom=zoom, layout=ipyl.Layout(width='650px', height='350px'))
feature_layer = ipyl.GeoJSON(data=data)
map.layers = [map.layers[0], feature_layer]
map
Hi, thanks for the lib. It's awesome!
I havn't found a way to init a map with certain bbox coords. While there is fitBounds() method in Leaflet documentation http://leafletjs.com/reference-1.3.0.html#map-fitbounds
Perhaps related to #57, but the height
and width
params of the Map()
class do not alter the output size whatsoever.
By default, ipyleaflet.DrawControl
facilitates drawing polylines, polygons, and circle markers. I want to be able to restrict this to polygons only. Is there any way of removing the circle marker control from the toolbar?
m = ipyleaflet.Map(center=(-27,134), zoom=4)
c = ipyleaflet.DrawControl(circle={}, circleMarker={}, circlemarker={},
CircleMarker={}, polyline={}, marker={}, polygon={})
m.add_control(c)
m
In ipyleaflet 0.6.0 (also tried 0.4.0) this only disables the polygon and polyline.
I followed the link in the read me and tried pointing binder to this repo but it failed to build. Seems to be an issue w/ a package requirement.
Here's the tail end of the log:
Removing intermediate container 65f9964d66e8
Step 26/27 : RUN conda env update -n root -f "environment.yml" && conda clean -t
ipsy
---> Running in d6bc1175151c
Fetching package metadata .....
Solving package specifications:
NoPackagesFoundError: Dependencies missing in current linux-64 channels:
- matplotlib -> numpy 1.11* -> blas 1.1 openblas -> openblas -> libgfortran
- matplotlib -> numpy 1.11* -> @blas_openblas
Removing intermediate container d6bc1175151c
The command '/bin/sh -c conda env update -n root -f "environment.yml" && conda c
lean -tipsy' returned a non-zero code: 1
Hi there, apologies if this is not the right place to post, I should be grateful if someone could tell me where the best place would be, to direct my enquiry.
I am using ipyleaflet for a project and I was wondering if there is any functionality to create a heat map on an ipyleaflet map from multiple latitude and longitude coordinates, because I don't see any examples of heatmaps in the examples folder. If there is no functionality for that, please could someone advise how I could generate a heatmap. Thanks
Adding a ``DrawControl()` to the map, and later on add a raster layer like:
io = ImageOverlay(url='http://ipython.org/_static/IPy_header.png', bounds=m.bounds)
m.add_layer(io)
When digitizing a new feature, the vector is drawn correctly, but behind the ImageOverlay.
Hi,
I would like to know what are the ipywidget version supported as it looks that with the 6.0.0 it is not working.
mouseover event not handled properly on some GeoJSON.
My enviroment is ubuntu 14.04/anaconda/jupyter notebook.
I've try to do someting with colours of circlemarkers and markers but nothing changes, colour still blue.
What i can do to fix it?
Thank you!
The embedded version of ipyleaflet is broken. It does not work in nbviewer and in the http://jupyter.org/widgets.html
It throws the: Uncaught Error: Script error for "@jupyter-widgets/base", needed by: https://unpkg.com/jupyter-leaflet@*/dist/index.js
.
the problem is the module_name
that is resolved to @jupyter-widgets/base
instead of the jupyter-js-widgets
as the ipywidgets are available under the jupyter-js-widgets
name by requirejs on nbviewer
and http://jupyter.org/widgets.html
If you get a non-descript error like
Could not create model:
Model name LeafletMapModel
Model module jupyter-leaflet
Model module version *
Script error for "jupyter-leaflet" http://requirejs.org/docs/errors.html#scripterror
after enabling ipyleaflet and trying to display a map in a notebook, upgrade ipyleaflet (via pip or whatever you use). In my case I seem to have had some version mismatches. Sadly that was the only error message and it was not helpful at all
I have
m = Map(center=[-3.1, 37.4], zoom=10, layout=dict(width='1000px', height='400px'))
and it displays correctly, but
m.bounds
report wrong bounding box:
[(-3.3735983031347327, -3.3735983031347327), (-2.8250874941127346, 38.08685302734375)]
Seems like a typo somewhere, as first coordinate is repeated twice.
We should use the same method as in core notebook with the __webpack_public_path__
variable to handle the case of a URL prefix (which can't be known at the time when the javascript bundle is built).
Hi there,
first of all, thanks for the great library!
I'm wondering whether there is a way to use a Marker Cluster in ipyleaflet
, such as is available in folium
through the folium.MarkerCluster
?
If not, I wouldn't mind trying to add this functionality and provide a PR, if I can get some pointers as to how to go about implementing it.
Thanks!
Omri
Can anybody give advice on the following JS problem getting L.Control.Layer
Leaflet has a neat Layer Control that enables overlays (i.e., GroupLayers or GeoJSON layers) to be turned on on an off using a control. I created a Python Class LayerControl, from the existing DrawingControl as a model. Unfortunately my code does not work and I don't have enough JS experience to figure out why.
In a notebook I exercise my code by creating a map
from __future__ import print_function
from ipyleaflet import Map, Marker,TileLayer, LayerGroup, DrawControl, LayerControl
center = [34.6252978589571, -77.34580993652344]
zoom = 10
m = Map(center=center, zoom=zoom)
m
Then I create a LayerControl which I add to the map.
tile = TileLayer()
lg = LayerGroup(layers=[Marker(location=[m.south, m.east], title="Hello"),
Marker(location=center, title="Hello", draggable=True)])
lc = LayerControl(base_layers = [tile],overlays = [lg] )
m.add_control(lc)
I get this browser console error.
leaflet-src.js:7958 Uncaught (in promise) TypeError: Cannot read property 'addTo' of undefined(…)addControl @ leaflet-src.js:7958
(anonymous function) @ jupyter-leaflet.js:388
My understanding is addTo is defined in the L.Control class that L.Control.Layer is extended from. So either the inheritance is not set up properly or my code is not creating a valid L.Control.Layer
Additionally, I would like to be able to bind them to GeoJSON features where the data could be pulled via feature properties. This can be done through the Javascript interface using:
var myLayer = L.geoJson(geojsonMD, {
style: function (feature) {
return feature.properties.style;
},
onEachFeature: function (feature, layer) {
layer.bindPopup(feature.properties.name);
}
}
It would be nice if the 'style', 'onEachFeature', and 'filter' callbacks were implemented as well, but I understand if this is difficult to do over comm messages. I've tried to do it myself, but I haven't had any luck due to my poor knowledge of how ipywidgets work.
Trying load a map from one of the simple examples in Jupyter and am getting the following:
tabbar.js:303 Uncaught Error: Script error for "jupyter-leaflet"
http://requirejs.org/docs/errors.html#scripterror
at makeError (require.js?v=6da8be3…:165)
at HTMLScriptElement.onScriptError (require.js?v=6da8be3…:1732)
makeError @ require.js?v=6da8be3…:165
onScriptError @ require.js?v=6da8be3…:1732
then this one twice:
tabbar.js:303 Uncaught Error: Script error for "jupyter-leaflet"
http://requirejs.org/docs/errors.html#scripterror
at makeError (require.js?v=6da8be3…:165)
at HTMLScriptElement.onScriptError (require.js?v=6da8be3…:1732)
I get this error that I don't undertand (on Windows/Winpython):
Disabling terminals plugin because they are not available on the server
main.bundle.js:170990 Starting WebSocket: ws://localhost:8888/api/kernels/7e61aa74-e3f6-4fa0-804d-fc09c2dae816
main.bundle.js:171758 Kernel: connected (7e61aa74-e3f6-4fa0-804d-fc09c2dae816)
main.bundle.js:148306 Could not instantiate widget
(anonymous) @ main.bundle.js:148306
main.bundle.js:49724 Error: Could not create a model.
at promiseRejection (main.bundle.js:49724)
at <anonymous>
promiseRejection @ main.bundle.js:49724
main.bundle.js:148306 Could not instantiate widget
(anonymous) @ main.bundle.js:148306
main.bundle.js:49724 Error: Could not create a model.
at promiseRejection (main.bundle.js:49724)
at <anonymous>
promiseRejection @ main.bundle.js:49724
main.bundle.js:148306 Could not instantiate widget
(anonymous) @ main.bundle.js:148306
main.bundle.js:49724 Error: Could not create a model.
at promiseRejection (main.bundle.js:49724)
at <anonymous>
promiseRejection @ main.bundle.js:49724
main.bundle.js:148306 Could not instantiate widget
(anonymous) @ main.bundle.js:148306
main.bundle.js:49724 Error: Could not create a model.
at promiseRejection (main.bundle.js:49724)
at <anonymous>
promiseRejection @ main.bundle.js:49724
main.bundle.js:153773 Error displaying widget
main.bundle.js:153774 Module jupyter-leaflet, semver range 0.4.0 is not registered as a widget module
lab:1 Uncaught (in promise) Module jupyter-leaflet, semver range 0.4.0 is not registered as a widget module
What may I check ?
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.