2016-12-16 16:52:16 +01:00
|
|
|
import React from 'react'
|
|
|
|
|
2017-01-09 22:37:21 +01:00
|
|
|
import GlSpec from 'mapbox-gl-style-spec/reference/latest.js'
|
2016-12-21 14:36:09 +01:00
|
|
|
import InputBlock from '../inputs/InputBlock'
|
|
|
|
import StringInput from '../inputs/StringInput'
|
|
|
|
import SelectInput from '../inputs/SelectInput'
|
|
|
|
import Modal from './Modal'
|
|
|
|
import colors from '../../config/colors'
|
2016-12-16 16:52:16 +01:00
|
|
|
|
|
|
|
class SettingsModal extends React.Component {
|
|
|
|
static propTypes = {
|
2016-12-20 16:08:49 +01:00
|
|
|
mapStyle: React.PropTypes.object.isRequired,
|
2016-12-16 16:52:16 +01:00
|
|
|
onStyleChanged: React.PropTypes.func.isRequired,
|
2016-12-21 16:11:08 +01:00
|
|
|
isOpen: React.PropTypes.bool.isRequired,
|
2016-12-22 16:35:31 +01:00
|
|
|
onOpenToggle: React.PropTypes.func.isRequired,
|
2016-12-16 16:52:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
}
|
|
|
|
|
2016-12-29 17:32:23 +01:00
|
|
|
changeStyleProperty(property, value) {
|
|
|
|
const changedStyle = {
|
|
|
|
...this.props.mapStyle,
|
|
|
|
[property]: value
|
|
|
|
}
|
2016-12-16 16:52:16 +01:00
|
|
|
this.props.onStyleChanged(changedStyle)
|
|
|
|
}
|
|
|
|
|
2016-12-29 17:32:23 +01:00
|
|
|
changeMetadataProperty(property, value) {
|
2016-12-22 18:08:42 +01:00
|
|
|
const changedStyle = {
|
|
|
|
...this.props.mapStyle,
|
|
|
|
metadata: {
|
|
|
|
...this.props.mapStyle.metadata,
|
2016-12-29 17:32:23 +01:00
|
|
|
[property]: value
|
2016-12-22 18:08:42 +01:00
|
|
|
}
|
|
|
|
}
|
2016-12-16 17:13:05 +01:00
|
|
|
this.props.onStyleChanged(changedStyle)
|
|
|
|
}
|
|
|
|
|
2016-12-16 16:52:16 +01:00
|
|
|
render() {
|
2016-12-28 21:50:47 +01:00
|
|
|
const metadata = this.props.mapStyle.metadata || {}
|
2016-12-21 16:50:34 +01:00
|
|
|
const inputProps = { }
|
2016-12-21 14:36:09 +01:00
|
|
|
return <Modal
|
2016-12-21 16:11:08 +01:00
|
|
|
isOpen={this.props.isOpen}
|
2016-12-22 16:35:31 +01:00
|
|
|
onOpenToggle={this.props.onOpenToggle}
|
2017-01-09 22:37:21 +01:00
|
|
|
title={'Style Settings'}
|
2016-12-21 14:36:09 +01:00
|
|
|
>
|
2017-01-09 22:37:21 +01:00
|
|
|
<InputBlock label={"Name"} doc={GlSpec['$root'].name.doc}>
|
2016-12-21 14:36:09 +01:00
|
|
|
<StringInput {...inputProps}
|
2016-12-20 16:08:49 +01:00
|
|
|
value={this.props.mapStyle.name}
|
2016-12-29 17:32:23 +01:00
|
|
|
onChange={this.changeStyleProperty.bind(this, "name")}
|
2016-12-16 16:52:16 +01:00
|
|
|
/>
|
2016-12-21 14:36:09 +01:00
|
|
|
</InputBlock>
|
2017-01-09 22:37:21 +01:00
|
|
|
<InputBlock label={"Owner"} doc={"Owner ID of the style. Used by Mapbox or future style APIs."}>
|
2016-12-21 14:36:09 +01:00
|
|
|
<StringInput {...inputProps}
|
2016-12-20 16:08:49 +01:00
|
|
|
value={this.props.mapStyle.owner}
|
2016-12-29 17:32:23 +01:00
|
|
|
onChange={this.changeStyleProperty.bind(this, "owner")}
|
2016-12-16 16:52:16 +01:00
|
|
|
/>
|
2016-12-21 14:36:09 +01:00
|
|
|
</InputBlock>
|
2017-01-09 22:37:21 +01:00
|
|
|
<InputBlock label={"Sprite URL"} doc={GlSpec['$root'].sprite.doc}>
|
2016-12-21 14:36:09 +01:00
|
|
|
<StringInput {...inputProps}
|
2016-12-20 16:08:49 +01:00
|
|
|
value={this.props.mapStyle.sprite}
|
2016-12-29 17:32:23 +01:00
|
|
|
onChange={this.changeStyleProperty.bind(this, "sprite")}
|
2016-12-16 16:52:16 +01:00
|
|
|
/>
|
2016-12-21 14:36:09 +01:00
|
|
|
</InputBlock>
|
|
|
|
|
2017-01-09 22:37:21 +01:00
|
|
|
<InputBlock label={"Glyphs URL"} doc={GlSpec['$root'].glyphs.doc}>
|
2016-12-21 14:36:09 +01:00
|
|
|
<StringInput {...inputProps}
|
2016-12-20 16:08:49 +01:00
|
|
|
value={this.props.mapStyle.glyphs}
|
2016-12-29 17:32:23 +01:00
|
|
|
onChange={this.changeStyleProperty.bind(this, "glyphs")}
|
2016-12-16 17:13:05 +01:00
|
|
|
/>
|
2016-12-21 14:36:09 +01:00
|
|
|
</InputBlock>
|
|
|
|
|
2017-01-09 22:37:21 +01:00
|
|
|
<InputBlock label={"Access Token"} doc={"Public access token for Mapbox GL."}>
|
2016-12-28 21:50:47 +01:00
|
|
|
<StringInput {...inputProps}
|
|
|
|
value={metadata['maputnik:access_token']}
|
2016-12-29 17:32:23 +01:00
|
|
|
onChange={this.changeMetadataProperty.bind(this, "maputnik:access_token")}
|
2016-12-28 21:50:47 +01:00
|
|
|
/>
|
|
|
|
</InputBlock>
|
2016-12-21 14:36:09 +01:00
|
|
|
|
2017-01-09 22:37:21 +01:00
|
|
|
<InputBlock label={"Style Renderer"} doc={"Choose the default Maputnik renderer for this style."}>
|
2016-12-21 14:36:09 +01:00
|
|
|
<SelectInput {...inputProps}
|
|
|
|
options={[
|
|
|
|
['mbgljs', 'MapboxGL JS'],
|
2016-12-24 14:42:57 +01:00
|
|
|
['ol3', 'Open Layers 3'],
|
2016-12-21 14:36:09 +01:00
|
|
|
]}
|
2016-12-28 21:50:47 +01:00
|
|
|
value={metadata['maputnik:renderer'] || 'mbgljs'}
|
2016-12-29 17:32:23 +01:00
|
|
|
onChange={this.changeMetadataProperty.bind(this, 'maputnik:renderer')}
|
2016-12-16 17:13:05 +01:00
|
|
|
/>
|
2016-12-21 14:36:09 +01:00
|
|
|
</InputBlock>
|
|
|
|
</Modal>
|
2016-12-16 16:52:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default SettingsModal
|