-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use ExtrudedPathLayer for GpxLayer paths (#193)
* fix: use ExtrudedPathLayer for GpxLayer paths * test: update story snapshots
- Loading branch information
Showing
11 changed files
with
158 additions
and
192 deletions.
There are no files selected for viewing
Binary file modified
BIN
+12.7 KB
(170%)
__snapshots__/chromium_layers-gpx-layer--gpx-layer-default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+23.9 KB
(230%)
__snapshots__/chromium_layers-gpx-layer--gpx-layer-line-style.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+8.13 KB
(150%)
__snapshots__/webkit_layers-gpx-layer--gpx-layer-default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+17.5 KB
(190%)
__snapshots__/webkit_layers-gpx-layer--gpx-layer-line-style.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
import { DeckGL } from "@deck.gl/react"; | ||
import { StreetLayer } from "../street-layer"; | ||
import { useState } from "react"; | ||
import * as React from "react"; | ||
import { GpxLayer, GpxLayerProps } from "./gpx-layer"; | ||
import { CompositeLayer } from "@deck.gl/core"; | ||
import { Map } from "react-map-gl/maplibre"; | ||
import type { StoryObj } from "@storybook/react"; | ||
import { | ||
JR_ACTIVITY_FILE, | ||
JR_INITIAL_VIEW_STATE, | ||
JR_PITCHED_VIEW_STATE, | ||
} from "../../constant.stories"; | ||
import { HillLayer } from "../hill-layer"; | ||
import { getRgba } from "../util.stories"; | ||
|
||
export default { | ||
title: "Layers / GPX Layer", | ||
tags: ["autodocs"], | ||
parameters: { | ||
docs: { | ||
story: { | ||
height: "600px", | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
const defaultLayerProps = { | ||
id: "gpx-layer", | ||
data: JR_ACTIVITY_FILE, | ||
}; | ||
|
||
export const GPXLayerDefault: StoryObj = { | ||
render: () => { | ||
const layer = new GpxLayer({ ...defaultLayerProps }); | ||
|
||
return ( | ||
<DeckGL | ||
layers={[layer]} | ||
initialViewState={JR_INITIAL_VIEW_STATE} | ||
controller | ||
></DeckGL> | ||
); | ||
}, | ||
}; | ||
|
||
export const GPXLayerLineStyle: StoryObj<{ color: string } & GpxLayerProps> = { | ||
args: { | ||
color: "blue", | ||
lineWidthMinPixels: 5, | ||
}, | ||
render: ({ color, lineWidthMinPixels }) => { | ||
const getLineColor = getRgba(color); | ||
|
||
const layer = new GpxLayer({ | ||
...defaultLayerProps, | ||
lineWidthMinPixels, | ||
getLineColor, | ||
}); | ||
|
||
return ( | ||
<DeckGL | ||
layers={[layer]} | ||
initialViewState={JR_PITCHED_VIEW_STATE} | ||
controller | ||
></DeckGL> | ||
); | ||
}, | ||
}; | ||
|
||
export const GpxWms: StoryObj = { | ||
render: () => { | ||
const gpxLayer = new GpxLayer({ | ||
...defaultLayerProps, | ||
}); | ||
|
||
const layers = [gpxLayer, new StreetLayer()]; | ||
|
||
return ( | ||
<DeckGL | ||
layers={layers} | ||
initialViewState={JR_PITCHED_VIEW_STATE} | ||
controller | ||
></DeckGL> | ||
); | ||
}, | ||
}; | ||
|
||
export const GpxSatteliteTerrain: StoryObj = { | ||
render: () => { | ||
const layerProps: GpxLayerProps = { | ||
...defaultLayerProps, | ||
getLineColor: [255, 255, 0], | ||
}; | ||
|
||
const gpxLayer = new GpxLayer({ ...layerProps }); | ||
|
||
const layers = [gpxLayer, new HillLayer()]; | ||
|
||
return ( | ||
<DeckGL | ||
layers={layers} | ||
initialViewState={JR_PITCHED_VIEW_STATE} | ||
controller | ||
></DeckGL> | ||
); | ||
}, | ||
tags: ["no-visual-test"], | ||
}; | ||
|
||
export function GpxMapTerrain() { | ||
const gpxLayer = new GpxLayer({ ...defaultLayerProps }) as CompositeLayer; | ||
|
||
const [API_KEY] = useState(import.meta.env.VITE_MAPTILER_API_KEY); | ||
const layers = [gpxLayer]; | ||
const mapStyle = `https://api.maptiler.com/maps/streets-v2/style.json?key=${API_KEY}`; | ||
|
||
return ( | ||
<DeckGL | ||
style={{ position: "absolute", zIndex: "100" }} | ||
layers={layers} | ||
initialViewState={JR_INITIAL_VIEW_STATE} | ||
controller | ||
> | ||
<Map | ||
mapStyle={mapStyle} | ||
style={{ position: "relative", zIndex: "-100" }} | ||
/> | ||
</DeckGL> | ||
); | ||
} | ||
GpxMapTerrain.tags = ["no-visual-test"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { GeoJsonLayer, type GeoJsonLayerProps } from "@deck.gl/layers"; | ||
import { Color } from "@deck.gl/core"; | ||
import { GPXLoader, TCXLoader } from "@loaders.gl/kml"; | ||
import { ExtrudedPathLayer } from "../extruded-path-layer/extruded-path-layer"; | ||
|
||
export type GpxLayerProps = GeoJsonLayerProps; | ||
|
||
export class GpxLayer extends GeoJsonLayer {} | ||
|
||
const defaultProps = { | ||
...GeoJsonLayer.defaultProps, | ||
lineWidthMinPixels: 3, | ||
getLineColor: [255, 255, 0] as Color, | ||
loaders: [GPXLoader, TCXLoader], | ||
_subLayerProps: { | ||
linestrings: { | ||
type: ExtrudedPathLayer, | ||
getSideColor: [120, 120, 120, 255], | ||
}, | ||
}, | ||
}; | ||
|
||
GpxLayer.defaultProps = defaultProps; | ||
GpxLayer.layerName = "GpxLayer"; |