Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to give border radius to map in react native?

MapView inside a container view

<View style={styles.container}>
  <MapView style={[styles.map]}
    initialRegion={{
      latitude: 18.978189,
      longitude: 73.024911,
      latitudeDelta: 0.0922,
      longitudeDelta: 0.0421,
    }}
  />
</View>

To give curved border to my map i gave borderRadius to the container view

const styles = {
 container:{
   marginTop:20,
   borderWidth:1,
   borderRadius:20
 },
 map:{
   height:200,
 },
}

This gave border to my view and my view is actually getting the borderRadius, i cross checked it by giving borderWidth:1. But my map is not getting this border of container. Maps corner get out of the container views border. What should i do to give borderRadius to my map.

like image 405
Vaibhav Shukla Avatar asked Mar 14 '17 05:03

Vaibhav Shukla


People also ask

How do I add a border radius in react native?

Border Radius in React NativeThe borderRadius property can be set as the style attribute to any element. It takes a value in pixels and assigns that value to the overall border radius of that UI element. By default, the border radius of any element is 0 if you haven't added that style attribute to that element.

How do I give border width in react native?

To set a border, you must first set borderWidth. borderWidth is the size of the border, and it's always a number. You can either set a borderWidth that applies to the entire component or choose which borderWidth you want to set specifically (top, right, bottom, or left).


1 Answers

You can set

overflow: 'hidden' 

in your container. It should hide the overflow of the mapView.

like image 178
MattYao Avatar answered Oct 23 '22 02:10

MattYao