Skip to content

Commit

Permalink
refactoring(Layer): deprecate labelEnable option Layer and replace by…
Browse files Browse the repository at this point in the history
… addLabelLayer.
  • Loading branch information
gchoqueux committed Apr 26, 2021
1 parent 67f25a1 commit 082d22c
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/plugins_vrt.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
haloWidth: 1,
},
}),
labelEnabled: true,
addLabelLayer: true,
});

return view.addLayer(velibLayer);
Expand Down
2 changes: 1 addition & 1 deletion examples/source_file_gpx_raster.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
transparent: true,
source: gpxSource,
style: gpxStyle,
labelEnabled: true,
addLabelLayer: true,
});

return view.addLayer(gpxLayer);
Expand Down
2 changes: 1 addition & 1 deletion examples/source_file_kml_raster.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
transparent: true,
source: kmlSource,
style: kmlStyle,
labelEnabled: true,
addLabelLayer: true,
});

debug.createTileDebugUI(menuGlobe.gui, view);
Expand Down
2 changes: 1 addition & 1 deletion examples/source_file_shapefile.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
var velibLayer = new itowns.ColorLayer('velib', {
source: velibSource,
style: velibStyle,
labelEnabled: true,
addLabelLayer: true,
});

debug.createTileDebugUI(menuGlobe.gui, view);
Expand Down
2 changes: 1 addition & 1 deletion examples/vector_tile_dragndrop.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
var layer = new itowns.ColorLayer(style.name + ' ' + id, {
source,
noTextureParentOutsideLimit: true,
labelEnabled: true,
addLabelLayer: true,
});

view.addLayer(layer).then(() => {
Expand Down
2 changes: 1 addition & 1 deletion examples/vector_tile_raster_2d.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

var mvtLayer = new itowns.ColorLayer('MVT', {
source: mvtSource,
labelEnabled: true,
addLabelLayer: true,
});

view.addLayer(mvtLayer).then(menuGlobe.addLayerGUI.bind(menuGlobe));
Expand Down
2 changes: 1 addition & 1 deletion examples/vector_tile_raster_3d.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
var mvtLayer = new itowns.ColorLayer('MVT', {
source: mvtSource,
fx: 2.5,
labelEnabled: true,
addLabelLayer: true,
});

view.addLayer(mvtLayer);
Expand Down
6 changes: 5 additions & 1 deletion src/Core/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ function _preprocessLayer(view, layer, parentLayer) {

if (layer.isLabelLayer) {
view.mainLoop.gfxEngine.label2dRenderer.registerLayer(layer);
} else if (layer.labelEnabled) {
} else if (layer.labelEnabled || layer.addLabelLayer) {
if (layer.labelEnabled) {
// eslint-disable-next-line no-console
console.info('layer.labelEnabled is deprecated use addLabelLayer, instead of');
}
// Because the features are shared between layer and labelLayer.
layer.buildExtent = true;
const labelLayer = new LabelLayer(`${layer.id}-label`, {
Expand Down
2 changes: 1 addition & 1 deletion src/Layer/LabelLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const _extent = new Extent('EPSG:4326', 0, 0, 0, 0);

/**
* A layer to handle a bunch of `Label`. This layer can be created on its own,
* but it is better to use the option `labelEnabled` on another `Layer` to let
* but it is better to use the option `addLabelLayer` on another `Layer` to let
* it work with it (see the `vector_tile_raster_2d` example).
*
* @property {boolean} isLabelLayer - Used to checkout whether this layer is a
Expand Down
4 changes: 2 additions & 2 deletions src/Layer/Layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import Cache from 'Core/Scheduler/Cache';
* @property {Promise} whenReady - this promise is resolved when the layer is added and all initializations are done.
* This promise is resolved with this layer.
* This promise is returned by [View#addLayer]{@link View}.
* @property {boolean} [labelEnabled=false] - Used to tell if this layer has
* @property {boolean} [addLabelLayer=false] - Used to tell if this layer has
* labels to display from its data. For example, it needs to be set to `true`
* for a layer with vector tiles.
* for a layer with vector tiles. If it's `true` a new `LabelLayer` is added and attached to this `Layer`.
* @property {object} [zoom] - This property is used only the layer is attached to [TiledGeometryLayer]{@link TiledGeometryLayer}.
* By example,
* The layer checks the tile zoom level to determine if the layer is visible in this tile.
Expand Down
2 changes: 1 addition & 1 deletion test/unit/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('Viewer', function () {
crs: 'EPSG:4326',
});

colorLayer = new ColorLayer('l0', { source, labelEnabled: true, crs: 'EPSG:4326' });
colorLayer = new ColorLayer('l0', { source, addLabelLayer: true, crs: 'EPSG:4326' });
colorLayer2 = new ColorLayer('l1', { source });
});

Expand Down

0 comments on commit 082d22c

Please sign in to comment.