Skip to content
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

Add globe/mercator button #963

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
32 changes: 31 additions & 1 deletion src/components/ModalSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import latest from '@maplibre/maplibre-gl-style-spec/dist/latest.json'
import type {LightSpecification, StyleSpecification, TerrainSpecification, TransitionSpecification} from 'maplibre-gl'
import type {LightSpecification, ProjectionSpecification, StyleSpecification, TerrainSpecification, TransitionSpecification} from 'maplibre-gl'
import { WithTranslation, withTranslation } from 'react-i18next';

import FieldArray from './FieldArray'
Expand Down Expand Up @@ -59,6 +59,25 @@
});
}

changeProjectionProperty(property: keyof ProjectionSpecification, value: any) {
const projection = {
...this.props.mapStyle.projection,
}

if (value === undefined) {
delete projection[property];
}
else {
// @ts-ignore
projection[property] = value;
}

this.props.onStyleChanged({
...this.props.mapStyle,
projection,
});
}

changeTerrainProperty(property: keyof TerrainSpecification, value: any) {
const terrain = {
...this.props.mapStyle.terrain,
Expand Down Expand Up @@ -102,6 +121,7 @@
const light = this.props.mapStyle.light || {};
const transition = this.props.mapStyle.transition || {};
const terrain = this.props.mapStyle.terrain || {} as TerrainSpecification;
const projection = this.props.mapStyle.projection || {} as ProjectionSpecification;

return <Modal
data-wd-key="modal:settings"
Expand Down Expand Up @@ -208,6 +228,16 @@
onChange={this.changeLightProperty.bind(this, "anchor")}
/>

<FieldEnum
label={"projection type"}
fieldSpec={latest.projection.type}
name="projection type"
value={projection.type as string}
options={Object.keys(latest.projection.type.values)}

Check failure on line 236 in src/components/ModalSettings.tsx

View workflow job for this annotation

GitHub Actions / build artifacts

Property 'values' does not exist on type '{ type: string; doc: string; default: string; "property-type": string; transition: boolean; expression: { interpolated: boolean; parameters: string[]; }; }'.

Check failure on line 236 in src/components/ModalSettings.tsx

View workflow job for this annotation

GitHub Actions / build on ubuntu-latest

Property 'values' does not exist on type '{ type: string; doc: string; default: string; "property-type": string; transition: boolean; expression: { interpolated: boolean; parameters: string[]; }; }'.

Check failure on line 236 in src/components/ModalSettings.tsx

View workflow job for this annotation

GitHub Actions / build on windows-latest

Property 'values' does not exist on type '{ type: string; doc: string; default: string; "property-type": string; transition: boolean; expression: { interpolated: boolean; parameters: string[]; }; }'.

Check failure on line 236 in src/components/ModalSettings.tsx

View workflow job for this annotation

GitHub Actions / build on macos-latest

Property 'values' does not exist on type '{ type: string; doc: string; default: string; "property-type": string; transition: boolean; expression: { interpolated: boolean; parameters: string[]; }; }'.
default={latest.projection.type.default}
onChange={this.changeProjectionProperty.bind(this, "type")}
/>

<FieldColor
label={t("Light color")}
fieldSpec={latest.light.color}
Expand Down
Loading