Skip to content

Commit 93111b6

Browse files
authored
fix(layers): correctly identify elevationData strings using TMS (#9712)
1 parent 54d0387 commit 93111b6

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

docs/api-reference/geo-layers/terrain-layer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {TerrainLayerDemo} from '@site/src/doc-demos/geo-layers';
66

77
The `TerrainLayer` reconstructs mesh surfaces from height map images, e.g. [Mapzen Terrain Tiles](https://github.com/tilezen/joerd/blob/master/docs/formats.md), which encodes elevation into R,G,B values.
88

9-
When `elevationData` is supplied with a URL template, i.e. a string containing `'{x}'` and `'{y}'`, it loads terrain tiles on demand using a `TileLayer` and renders a mesh for each tile. If `elevationData` is an absolute URL, a single mesh is used, and the `bounds` prop is required to position it into the world space.
9+
When `elevationData` is supplied with a URL template, i.e. a string containing `'{x}'` and `'{y}'` (or `'{-y}'` for TMS tiles), it loads terrain tiles on demand using a `TileLayer` and renders a mesh for each tile. If `elevationData` is an absolute URL, a single mesh is used, and the `bounds` prop is required to position it into the world space.
1010

1111

1212
import Tabs from '@theme/Tabs';

modules/geo-layers/src/terrain-layer/terrain-layer.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,7 @@ export default class TerrainLayer<ExtraPropsT extends {} = {}> extends Composite
135135
if (elevationDataChanged) {
136136
const {elevationData} = props;
137137
const isTiled =
138-
elevationData &&
139-
(Array.isArray(elevationData) ||
140-
(elevationData.includes('{x}') && elevationData.includes('{y}')));
138+
elevationData && (Array.isArray(elevationData) || isTileSetURL(elevationData));
141139
this.setState({isTiled});
142140
}
143141

@@ -355,3 +353,6 @@ export default class TerrainLayer<ExtraPropsT extends {} = {}> extends Composite
355353
);
356354
}
357355
}
356+
357+
const isTileSetURL = (url: string): boolean =>
358+
url.includes('{x}') && (url.includes('{y}') || url.includes('{-y}'));

0 commit comments

Comments
 (0)