mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-11-10 07:57:45 +01:00
Merge pull request #236 from orangemug/fix/issue-234
Added guard in fetchSources
This commit is contained in:
commit
6b22c9130f
2 changed files with 6 additions and 1 deletions
|
@ -202,7 +202,7 @@ export default class App extends React.Component {
|
|||
layers: []
|
||||
};
|
||||
|
||||
if(!this.state.sources.hasOwnProperty(key) && val.type === "vector") {
|
||||
if(!this.state.sources.hasOwnProperty(key) && val.type === "vector" && val.hasOwnProperty("url")) {
|
||||
let url = val.url;
|
||||
try {
|
||||
url = mapboxUtil.normalizeSourceURL(url, MapboxGl.accessToken);
|
||||
|
@ -215,6 +215,10 @@ export default class App extends React.Component {
|
|||
return response.json();
|
||||
})
|
||||
.then((json) => {
|
||||
if(!json.hasOwnProperty("vector_layers")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create new objects before setState
|
||||
const sources = Object.assign({}, this.state.sources);
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ function indexOfLayer(layers, layerId) {
|
|||
function replaceAccessToken(mapStyle) {
|
||||
const omtSource = mapStyle.sources.openmaptiles
|
||||
if(!omtSource) return mapStyle
|
||||
if(!omtSource.hasOwnProperty("url")) return mapStyle
|
||||
|
||||
const metadata = mapStyle.metadata || {}
|
||||
const accessToken = metadata['maputnik:openmaptiles_access_token'] || tokens.openmaptiles
|
||||
|
|
Loading…
Reference in a new issue