Skip to content

Commit

Permalink
fix(open street maps): map size
Browse files Browse the repository at this point in the history
- map size will now be fixed, independent of orientation
- this needs to be done due to a bug in react-native 0.63
(facebook/react-native#29451)

SVA-86
  • Loading branch information
Julian Kwast authored and digorath committed Dec 11, 2020
1 parent 3d88c7e commit 8f8e570
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/components/map/WebViewMap.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable react-native/no-color-literals */
import React, { useCallback } from 'react';
import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
import { Dimensions, StyleProp, View, ViewStyle } from 'react-native';
import { MapMarker, WebViewLeaflet, WebviewLeafletMessage } from 'react-native-webview-leaflet';

type Props = {
Expand Down Expand Up @@ -29,7 +29,7 @@ export const WebViewMap = ({
);

return (
<View style={[styles.map, style]}>
<View style={style}>
<WebViewLeaflet
backgroundColor={'gray'}
onMessageReceived={messageHandler}
Expand All @@ -49,9 +49,16 @@ export const WebViewMap = ({
);
};

const styles = StyleSheet.create({
map: {
aspectRatio: 16 / 9,
width: '100%'
// this will only be set at the start of the app, so this will be the width of portrait mode
// needs to be done due to react native 0.63 bug for android
// https://github.com/facebook/react-native/issues/29451
const width = Dimensions.get('window').width;

WebViewMap.defaultProps = {
style: {
alignSelf: 'center',
height: 9/16 * width,
width
}
});
};

0 comments on commit 8f8e570

Please sign in to comment.