forked from react-native-maps/react-native-maps
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…eact-native-maps#840) * Fixes react-native-maps#470 for iOS and Apple Maps This will add support for `legalLabelInsets` prop on iOS with Apple Maps. Code is adapted from RN core. * Pluralize updateLegalLabelInset(s) for consistency * Removed arrow notation * Added legalLabelInsets example
- Loading branch information
Showing
3 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
import React from 'react'; | ||
import { | ||
StyleSheet, | ||
View, | ||
Text, | ||
Dimensions, | ||
} from 'react-native'; | ||
|
||
import MapView from 'react-native-maps'; | ||
|
||
const screen = Dimensions.get('window'); | ||
|
||
class LegalLabel extends React.Component { | ||
static propTypes = { | ||
provider: MapView.ProviderPropType, | ||
} | ||
|
||
render() { | ||
const latlng = { | ||
latitude: 37.78825, | ||
longitude: -122.4324, | ||
}; | ||
|
||
const ASPECT_RATIO = screen.width / screen.height; | ||
const LATITUDE_DELTA = 0.0922; | ||
const LONGITUDE_DELTA = LATITUDE_DELTA * ASPECT_RATIO; | ||
|
||
return ( | ||
<View style={{ ...StyleSheet.absoluteFillObject }}> | ||
<MapView | ||
provider={this.props.provider} | ||
style={styles.map} | ||
legalLabelInsets={{ bottom: 10, right: 10 }} | ||
initialRegion={{ | ||
...latlng, | ||
latitudeDelta: LATITUDE_DELTA, | ||
longitudeDelta: LONGITUDE_DELTA, | ||
}} | ||
> | ||
<MapView.Marker coordinate={latlng} /> | ||
</MapView> | ||
|
||
<View style={styles.username}> | ||
<Text style={styles.usernameText}>Username</Text> | ||
</View> | ||
|
||
<View style={styles.bio}> | ||
<Text style={styles.bioText}> | ||
Bio description lorem ipsum Ullamco exercitation | ||
aliqua ullamco nostrud dolor et aliquip fugiat do | ||
aute fugiat velit in aliqua sit. | ||
</Text> | ||
</View> | ||
|
||
<View style={styles.photo}> | ||
<View style={styles.photoInner}> | ||
<Text style={styles.photoText}> | ||
Profile Photo | ||
</Text> | ||
</View> | ||
</View> | ||
</View> | ||
); | ||
} | ||
} | ||
|
||
const padding = 10; | ||
const photoSize = 80; | ||
const mapHeight = screen.height - 130; | ||
const styles = StyleSheet.create({ | ||
bio: { | ||
marginHorizontal: padding, | ||
marginBottom: 0, | ||
paddingVertical: padding / 2, | ||
}, | ||
bioText: { | ||
fontSize: 16, | ||
lineHeight: 16 * 1.5, | ||
}, | ||
username: { | ||
paddingLeft: photoSize + padding + padding, | ||
paddingTop: padding, | ||
}, | ||
usernameText: { | ||
fontSize: 36, | ||
lineHeight: 36, | ||
}, | ||
photo: { | ||
padding: 2, | ||
position: 'absolute', | ||
top: mapHeight - (photoSize / 2), | ||
left: padding, | ||
borderRadius: 5, | ||
borderWidth: StyleSheet.hairlineWidth, | ||
backgroundColor: '#ccc', | ||
width: photoSize, | ||
height: photoSize, | ||
}, | ||
photoInner: { | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
flex: 1, | ||
}, | ||
photoText: { | ||
fontSize: 9, | ||
textAlign: 'center', | ||
}, | ||
map: { | ||
height: mapHeight, | ||
}, | ||
}); | ||
|
||
module.exports = LegalLabel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters