-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Upgrade mapbox-gl #1400
base: feat#1289-simplified-aoi-creation
Are you sure you want to change the base?
fix: Upgrade mapbox-gl #1400
Changes from all commits
125b724
e227a9d
a4f7383
641463e
045deb6
e40b575
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,4 +1,8 @@ | ||||||
import { AnySourceImpl, Layer, Style } from 'mapbox-gl'; | ||||||
import { | ||||||
LayerSpecification, | ||||||
SourceSpecification, | ||||||
StyleSpecification | ||||||
} from 'mapbox-gl'; | ||||||
import React, { | ||||||
ReactNode, | ||||||
createContext, | ||||||
|
@@ -16,7 +20,7 @@ import { | |||||
|
||||||
export interface StylesContextType { | ||||||
updateStyle: (params: GeneratorStyleParams) => void; | ||||||
style?: Style; | ||||||
style?: StyleSpecification; | ||||||
updateMetaData?: (params: unknown) => void; | ||||||
metaData?: unknown; | ||||||
isCompared?: boolean; | ||||||
|
@@ -53,7 +57,7 @@ const generateStyle = ( | |||||
stylesData: Record<string, GeneratorStyleParams>, | ||||||
currentMapStyle | ||||||
) => { | ||||||
let sources: Record<string, AnySourceImpl> = {}; | ||||||
let sources: Record<string, SourceSpecification> = {}; | ||||||
let layers: ExtendedLayer[] = []; | ||||||
|
||||||
Object.entries(stylesData).forEach(([generatorId, generatorParams]) => { | ||||||
|
@@ -64,10 +68,12 @@ const generateStyle = ( | |||||
}; | ||||||
|
||||||
const generatorLayers = generatorParams.layers.map((generatorLayer) => { | ||||||
const metadata: ExtendedMetadata = generatorLayer.metadata ?? {}; | ||||||
metadata.generatorId = generatorId; | ||||||
const metadata: ExtendedMetadata = { | ||||||
...(generatorLayer.metadata ?? {}), | ||||||
generatorId | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops, this will only work if we don't pass There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we create a tech debt ticket to clean up typings around maps/sources/metadata? This seems to be a bit of a 🧶 (alt: a knotty situation) |
||||||
}; | ||||||
|
||||||
const mapLayer = { ...generatorLayer, metadata } as Layer; | ||||||
const mapLayer = { ...generatorLayer, metadata } as LayerSpecification; | ||||||
|
||||||
if (generatorParams.params?.hidden) { | ||||||
mapLayer.layout = { | ||||||
|
@@ -84,13 +90,19 @@ const generateStyle = ( | |||||
// Allow sort as it uses a copy of the array so mutating is ok | ||||||
/* eslint-disable-next-line fp/no-mutating-methods */ | ||||||
layers = [...layers].sort((layerA, layerB) => { | ||||||
const layerAOrder = layerA.metadata?.layerOrderPosition; | ||||||
const layerBOrder = layerB.metadata?.layerOrderPosition; | ||||||
const layerAOrder = | ||||||
(layerA.metadata as ExtendedMetadata).layerOrderPosition ?? | ||||||
'basemap-background'; | ||||||
const layerBOrder = | ||||||
(layerB.metadata as ExtendedMetadata).layerOrderPosition ?? | ||||||
'basemap-background'; | ||||||
const layerAIndex = LAYER_ORDER.indexOf(layerAOrder); | ||||||
const layerBIndex = LAYER_ORDER.indexOf(layerBOrder); | ||||||
const layerOrder = layerAIndex - layerBIndex; | ||||||
const generatorA = stylesData[layerA.metadata?.generatorId]; | ||||||
const generatorB = stylesData[layerB.metadata?.generatorId]; | ||||||
const generatorA = | ||||||
stylesData[(layerA.metadata as ExtendedMetadata).generatorId]; | ||||||
const generatorB = | ||||||
stylesData[(layerB.metadata as ExtendedMetadata).generatorId]; | ||||||
const generatorOrder = | ||||||
generatorA.params?.generatorOrder !== undefined && | ||||||
generatorB.params?.generatorOrder !== undefined | ||||||
|
@@ -146,7 +158,7 @@ export function Styles({ | |||||
Record<string, GeneratorStyleParams> | ||||||
>({}); | ||||||
|
||||||
const [style, setStyle] = useState<Style>({ | ||||||
const [style, setStyle] = useState<StyleSpecification>({ | ||||||
version: DEFAULT_MAPBOX_STYLE_VERSION, | ||||||
glyphs: DEFAULT_GLYPHS_SOURCE, | ||||||
sprite: DEFAULT_SPRITE_SOURCE, | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spread types may only be created from object types.ts(2698)
const projection: MbProjectionOptions