From e7b11d8bc9aae9c36273d7b3778fcb1a40014680 Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Thu, 5 Jan 2017 21:05:34 +0100 Subject: [PATCH] Ensure editor does not crash with raster layers --- src/components/icons/LayerIcon.jsx | 1 + src/components/map/MapboxGlMap.jsx | 3 ++- src/libs/apistore.js | 8 +++++--- src/libs/urlopen.js | 1 - 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/icons/LayerIcon.jsx b/src/components/icons/LayerIcon.jsx index 7259122..5c75c45 100644 --- a/src/components/icons/LayerIcon.jsx +++ b/src/components/icons/LayerIcon.jsx @@ -16,6 +16,7 @@ class LayerIcon extends React.Component { const iconProps = { style: this.props.style } switch(this.props.type) { case 'fill-extrusion': return + case 'raster': return case 'fill': return case 'background': return case 'line': return diff --git a/src/components/map/MapboxGlMap.jsx b/src/components/map/MapboxGlMap.jsx index 4de0f06..0a2eef8 100644 --- a/src/components/map/MapboxGlMap.jsx +++ b/src/components/map/MapboxGlMap.jsx @@ -93,9 +93,10 @@ export default class MapboxGlMap extends React.Component { style={{ position: "fixed", top: 0, + left: 550, bottom: 0, height: "100%", - width: "100%", + width: "75%", ...this.props.style, }}> diff --git a/src/libs/apistore.js b/src/libs/apistore.js index 27016ee..8cf60d9 100644 --- a/src/libs/apistore.js +++ b/src/libs/apistore.js @@ -31,12 +31,14 @@ export class ApiStyleStore { connection.onmessage = e => { if(!e.data) return console.log('Received style update from API') + let parsedStyle = style.emptyStyle try { - const updatedStyle = style.ensureStyleValidity(JSON.parse(e.data)) - this.onLocalStyleChange(updatedStyle) + parsedStyle = JSON.parse(e.data) } catch(err) { - console.error('Could not parse local style') + console.error(err) } + const updatedStyle = style.ensureStyleValidity(parsedStyle) + this.onLocalStyleChange(updatedStyle) } } diff --git a/src/libs/urlopen.js b/src/libs/urlopen.js index b5aa425..cb1256a 100644 --- a/src/libs/urlopen.js +++ b/src/libs/urlopen.js @@ -4,7 +4,6 @@ import style from './style.js' export function initialStyleUrl() { const initialUrl = url.parse(window.location.href, true) - console.log(initialUrl) return (initialUrl.query || {}).style }