Skip to content

Commit 12ebba7

Browse files
authored
Merge pull request #429 from martinRenou/localtilelayer
LocalTileLayer fix + doc fix
2 parents 2c36fff + ceea99d commit 12ebba7

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

docs/source/api_reference/local_tile_layer.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,21 @@ Example
99
from ipyleaflet import Map, LocalTileLayer
1010
1111
m = Map(center=(52.204793, 360.121558), zoom=9)
12-
m.add_layer(LocalTileLayer(url='./tiles/{z}/{x}/{y}.png'))
12+
m.add_layer(LocalTileLayer(path='tiles/{z}/{x}/{y}.png'))
1313
1414
m
1515
16+
Note that the behavior is different in Jupyter Notebook and in JupyterLab.
17+
18+
In the classic Jupyter Notebook, the path is relative to the Notebook you are working on.
19+
20+
In JupyterLab, the path is relative to the server (where you started JupyterLab) and you need to prefix the path with "files/".
21+
1622
Attributes
1723
----------
1824

1925
=============== ================= =====
2026
Attribute Default Value Doc
2127
=============== ================= =====
22-
url "" Relative URL (e.g. './tiles/{z}/{x}/{y}.png')
28+
path "" Relative URL (e.g. 'tiles/{z}/{x}/{y}.png' or 'files/tiles/{z}/{x}/{y}.png' in JupyterLab)
2329
=============== ================= =====

ipyleaflet/leaflet.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ class TileLayer(RasterLayer):
239239
attribution = Unicode('Map data (c) <a href="https://openstreetmap.org">OpenStreetMap</a> contributors').tag(sync=True, o=True)
240240
detect_retina = Bool(False).tag(sync=True, o=True)
241241
no_wrap = Bool(False).tag(sync=True, o=True)
242+
tms = Bool(False).tag(sync=True, o=True)
242243

243244
_load_callbacks = Instance(CallbackDispatcher, ())
244245

js/src/layers/LocalTileLayer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ var LeafletLocalTileLayerModel = LeafletTileLayerModel.extend({
1616

1717
var LeafletLocalTileLayerView = LeafletTileLayerView.extend({
1818
create_obj: function () {
19-
this.model.set('url', window.location.href.replace(/[^/]*$/, '') + this.model.get('path'));
19+
this.model.set('url', this.model.get('path'));
20+
this.model.save_changes();
2021
LeafletLocalTileLayerView.__super__.create_obj.apply(this, arguments);
2122
}
2223
});

js/src/layers/TileLayer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ var LeafletTileLayerModel = LeafletRasterLayerModel.extend({
1616
max_zoom : 18,
1717
tile_size : 256,
1818
attribution : 'Map data (c) <a href="https://openstreetmap.org">OpenStreetMap</a> contributors',
19-
detect_retina : false
19+
detect_retina : false,
20+
tms: false,
2021
})
2122
});
2223

0 commit comments

Comments
 (0)