mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2025-01-14 17:33:30 +01:00
commit
c8a004422f
3 changed files with 20 additions and 8 deletions
|
@ -32,6 +32,16 @@ export default class FunctionSpecProperty extends React.Component {
|
||||||
]),
|
]),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getFieldFunctionType(fieldSpec) {
|
||||||
|
if (fieldSpec.expression.interpolated) {
|
||||||
|
return "exponential"
|
||||||
|
}
|
||||||
|
if (fieldSpec.type === "number") {
|
||||||
|
return "interval"
|
||||||
|
}
|
||||||
|
return "categorical"
|
||||||
|
}
|
||||||
|
|
||||||
addStop = () => {
|
addStop = () => {
|
||||||
const stops = this.props.value.stops.slice(0)
|
const stops = this.props.value.stops.slice(0)
|
||||||
const lastStop = stops[stops.length - 1]
|
const lastStop = stops[stops.length - 1]
|
||||||
|
@ -80,12 +90,14 @@ export default class FunctionSpecProperty extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
makeDataFunction = () => {
|
makeDataFunction = () => {
|
||||||
|
const functionType = this.getFieldFunctionType(this.props.fieldSpec);
|
||||||
|
const stopValue = functionType === 'categorical' ? '' : 0;
|
||||||
const dataFunc = {
|
const dataFunc = {
|
||||||
property: "",
|
property: "",
|
||||||
type: "categorical",
|
type: functionType,
|
||||||
stops: [
|
stops: [
|
||||||
[{zoom: 6, value: 0}, this.props.value],
|
[{zoom: 6, value: stopValue}, this.props.value || stopValue],
|
||||||
[{zoom: 10, value: 0}, this.props.value]
|
[{zoom: 10, value: stopValue}, this.props.value || stopValue]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
this.props.onChange(this.props.fieldName, dataFunc)
|
this.props.onChange(this.props.fieldName, dataFunc)
|
||||||
|
|
|
@ -30,7 +30,7 @@ export default class DataProperty extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
getFieldFunctionType(fieldSpec) {
|
getFieldFunctionType(fieldSpec) {
|
||||||
if (fieldSpec.function === "interpolated") {
|
if (fieldSpec.expression.interpolated) {
|
||||||
return "exponential"
|
return "exponential"
|
||||||
}
|
}
|
||||||
if (fieldSpec.type === "number") {
|
if (fieldSpec.type === "number") {
|
||||||
|
@ -39,8 +39,8 @@ export default class DataProperty extends React.Component {
|
||||||
return "categorical"
|
return "categorical"
|
||||||
}
|
}
|
||||||
|
|
||||||
getDataFunctionTypes(functionType) {
|
getDataFunctionTypes(fieldSpec) {
|
||||||
if (functionType === "interpolated") {
|
if (fieldSpec.expression.interpolated) {
|
||||||
return ["categorical", "interval", "exponential"]
|
return ["categorical", "interval", "exponential"]
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -150,7 +150,7 @@ export default class DataProperty extends React.Component {
|
||||||
<SelectInput
|
<SelectInput
|
||||||
value={this.props.value.type}
|
value={this.props.value.type}
|
||||||
onChange={propVal => this.changeDataProperty("type", propVal)}
|
onChange={propVal => this.changeDataProperty("type", propVal)}
|
||||||
options={this.getDataFunctionTypes(this.props.fieldSpec.function)}
|
options={this.getDataFunctionTypes(this.props.fieldSpec)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -28,7 +28,7 @@ export default class FunctionButtons extends React.Component {
|
||||||
/>
|
/>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
if (this.props.fieldSpec['property-function'] && ['piecewise-constant', 'interpolated'].indexOf(this.props.fieldSpec['function']) !== -1) {
|
if (this.props.fieldSpec['property-type'] === 'data-driven') {
|
||||||
makeDataButton = <Button
|
makeDataButton = <Button
|
||||||
className="maputnik-make-data-function"
|
className="maputnik-make-data-function"
|
||||||
onClick={this.props.onDataClick}
|
onClick={this.props.onDataClick}
|
||||||
|
|
Loading…
Reference in a new issue