mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-28 16:51:20 +01:00
Added final bits for thunderforest integration
This commit is contained in:
parent
fd59f42819
commit
0384181ee1
5 changed files with 23 additions and 4 deletions
|
@ -22,7 +22,7 @@ import SurveyModal from './modals/SurveyModal'
|
|||
|
||||
import { downloadGlyphsMetadata, downloadSpriteMetadata } from '../libs/metadata'
|
||||
import * as styleSpec from '@mapbox/mapbox-gl-style-spec/style-spec'
|
||||
import style from '../libs/style.js'
|
||||
import style from '../libs/style'
|
||||
import { initialStyleUrl, loadStyleUrl } from '../libs/urlopen'
|
||||
import { undoMessages, redoMessages } from '../libs/diffmessage'
|
||||
import { loadDefaultStyle, StyleStore } from '../libs/stylestore'
|
||||
|
@ -407,7 +407,7 @@ export default class App extends React.Component {
|
|||
|
||||
mapRenderer() {
|
||||
const mapProps = {
|
||||
mapStyle: style.replaceAccessToken(this.state.mapStyle, {allowFallback: true}),
|
||||
mapStyle: style.replaceAccessTokens(this.state.mapStyle, {allowFallback: true}),
|
||||
options: this.state.mapOptions,
|
||||
onDataChange: (e) => {
|
||||
this.layerWatcher.analyzeMap(e.map)
|
||||
|
|
|
@ -10,7 +10,7 @@ import Button from '../Button'
|
|||
import Modal from './Modal'
|
||||
import MdFileDownload from 'react-icons/lib/md/file-download'
|
||||
import TiClipboard from 'react-icons/lib/ti/clipboard'
|
||||
import style from '../../libs/style.js'
|
||||
import style from '../../libs/style'
|
||||
import GitHub from 'github-api'
|
||||
import { CopyToClipboard } from 'react-copy-to-clipboard'
|
||||
|
||||
|
@ -235,7 +235,7 @@ class ExportModal extends React.Component {
|
|||
}
|
||||
|
||||
downloadStyle() {
|
||||
const tokenStyle = styleSpec.format(stripAccessTokens(style.replaceAccessToken(this.props.mapStyle)));
|
||||
const tokenStyle = styleSpec.format(stripAccessTokens(style.replaceAccessTokens(this.props.mapStyle)));
|
||||
|
||||
const blob = new Blob([tokenStyle], {type: "application/json;charset=utf-8"});
|
||||
saveAs(blob, this.props.mapStyle.id + ".json");
|
||||
|
@ -280,6 +280,12 @@ class ExportModal extends React.Component {
|
|||
onChange={this.changeMetadataProperty.bind(this, "maputnik:mapbox_access_token")}
|
||||
/>
|
||||
</InputBlock>
|
||||
<InputBlock label={"Thunderforest Access Token: "}>
|
||||
<StringInput
|
||||
value={(this.props.mapStyle.metadata || {})['maputnik:thunderforest_access_token']}
|
||||
onChange={this.changeMetadataProperty.bind(this, "maputnik:thunderforest_access_token")}
|
||||
/>
|
||||
</InputBlock>
|
||||
</p>
|
||||
|
||||
<Button onClick={this.downloadStyle.bind(this)}>
|
||||
|
|
|
@ -94,6 +94,14 @@ class SettingsModal extends React.Component {
|
|||
/>
|
||||
</InputBlock>
|
||||
|
||||
<InputBlock label={"Thunderforest Access Token"} doc={"Public access token for Thunderforest services."}>
|
||||
<StringInput {...inputProps}
|
||||
data-wd-key="modal-settings.maputnik:thunderforest_access_token"
|
||||
value={metadata['maputnik:thunderforest_access_token']}
|
||||
onChange={this.changeMetadataProperty.bind(this, "maputnik:thunderforest_access_token")}
|
||||
/>
|
||||
</InputBlock>
|
||||
|
||||
<InputBlock label={"Style Renderer"} doc={"Choose the default Maputnik renderer for this style."}>
|
||||
<SelectInput {...inputProps}
|
||||
data-wd-key="modal-settings.maputnik:renderer"
|
||||
|
|
|
@ -55,6 +55,10 @@ function indexOfLayer(layers, layerId) {
|
|||
}
|
||||
|
||||
function getAccessToken(key, mapStyle, opts) {
|
||||
if(key === "thunderforest_transport" || key === "thunderforest_outdoors") {
|
||||
key = "thunderforest";
|
||||
}
|
||||
|
||||
const metadata = mapStyle.metadata || {}
|
||||
let accessToken = metadata['maputnik:'+key+'_access_token'];
|
||||
|
||||
|
|
|
@ -154,6 +154,7 @@
|
|||
|
||||
.maputnik-public-source-id {
|
||||
font-weight: 400;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.maputnik-active-source-type-editor {
|
||||
|
|
Loading…
Reference in a new issue