Merge pull request #236 from orangemug/fix/issue-234

Added guard in fetchSources
This commit is contained in:
Orange Mug
2018-02-02 11:24:23 +00:00
committed by GitHub
2 changed files with 6 additions and 1 deletions

View File

@@ -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);