summaryrefslogtreecommitdiffhomepage
path: root/app/components/Map.js
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2018-06-01 16:13:10 +0200
committerAndrej Mihajlov <and@mullvad.net>2018-06-05 12:11:55 +0200
commitca2f6fbfcad7b73d4ea63ef46cb1cab943ec9087 (patch)
treeb1f7754eb50896ab3681e35fa4e08be642b940c9 /app/components/Map.js
parent5852c980980de53e00d76a0bdb4b41bf5c0f5b39 (diff)
downloadmullvadvpn-ca2f6fbfcad7b73d4ea63ef46cb1cab943ec9087.tar.xz
mullvadvpn-ca2f6fbfcad7b73d4ea63ef46cb1cab943ec9087.zip
Add formatted source code
Diffstat (limited to 'app/components/Map.js')
-rw-r--r--app/components/Map.js65
1 files changed, 33 insertions, 32 deletions
diff --git a/app/components/Map.js b/app/components/Map.js
index 3865e8975a..72298fd2ee 100644
--- a/app/components/Map.js
+++ b/app/components/Map.js
@@ -17,8 +17,8 @@ export type MapProps = {
type MapState = {
bounds: {
width: number,
- height: number
- }
+ height: number,
+ },
};
export default class Map extends Component<MapProps, MapState> {
@@ -31,18 +31,20 @@ export default class Map extends Component<MapProps, MapState> {
render() {
const { width, height } = this.state.bounds;
- const readyToRenderTheMap = (width > 0 && height > 0);
+ const readyToRenderTheMap = width > 0 && height > 0;
return (
- <View style={ this.props.style } onLayout={ this._onLayout }>
- { readyToRenderTheMap && (
- <SvgMap width={ width }
- height={ height }
- center={ this.props.center }
- offset={ this.props.offset }
- zoomLevel={ this._zoomLevel(this.props.zoomLevel) }
- showMarker={ this.props.showMarker }
- markerImagePath={ this._markerImage(this.props.markerStyle) } />
- ) }
+ <View style={this.props.style} onLayout={this._onLayout}>
+ {readyToRenderTheMap && (
+ <SvgMap
+ width={width}
+ height={height}
+ center={this.props.center}
+ offset={this.props.offset}
+ zoomLevel={this._zoomLevel(this.props.zoomLevel)}
+ showMarker={this.props.showMarker}
+ markerImagePath={this._markerImage(this.props.markerStyle)}
+ />
+ )}
</View>
);
}
@@ -53,14 +55,11 @@ export default class Map extends Component<MapProps, MapState> {
return (
oldProps.center[0] !== nextProps.center[0] ||
oldProps.center[1] !== nextProps.center[1] ||
-
oldProps.offset[0] !== nextProps.offset[0] ||
oldProps.offset[1] !== nextProps.offset[1] ||
-
oldProps.zoomLevel !== nextProps.zoomLevel ||
oldProps.showMarker !== nextProps.showMarker ||
oldProps.markerStyle !== nextProps.markerStyle ||
-
oldState.bounds.width !== nextState.bounds.width ||
oldState.bounds.height !== nextState.bounds.height
);
@@ -71,30 +70,32 @@ export default class Map extends Component<MapProps, MapState> {
bounds: {
width: layoutInfo.width,
height: layoutInfo.height,
- }
+ },
});
- }
+ };
// TODO: Remove zoom level in favor of center + coordinate span
_zoomLevel(variant: $PropertyType<MapProps, 'zoomLevel'>) {
- switch(variant) {
- case 'high': return 1;
- case 'medium': return 20;
- case 'low': return 40;
- default:
- throw new Error(`Invalid enumeration type: ${variant}`);
+ switch (variant) {
+ case 'high':
+ return 1;
+ case 'medium':
+ return 20;
+ case 'low':
+ return 40;
+ default:
+ throw new Error(`Invalid enumeration type: ${variant}`);
}
}
_markerImage(style: $PropertyType<MapProps, 'markerStyle'>) {
- switch(style) {
- case 'secure':
- return './assets/images/location-marker-secure.svg';
- case 'unsecure':
- return './assets/images/location-marker-unsecure.svg';
- default:
- throw new Error(`Invalid enumeration type: ${style}`);
+ switch (style) {
+ case 'secure':
+ return './assets/images/location-marker-secure.svg';
+ case 'unsecure':
+ return './assets/images/location-marker-unsecure.svg';
+ default:
+ throw new Error(`Invalid enumeration type: ${style}`);
}
}
-
}