2016-11-26 75 views
1

screen shot 2016-11-26 at 7 58 48 pm的Airbnb陣營本地地圖自定義標記在上面

當我說陣營本地地圖我指的是這個模塊居中文本:https://github.com/airbnb/react-native-maps

我如何居中文本上的這個標記,使得它的頂部適用於iOS和Android上的任何屏幕尺寸?在上面的屏幕截圖中,文本出現在標記的左上角。這是一個1.

代碼包括在下面。感謝您的任何指導!

<MapView.Marker 
    style ={{zIndex: this.state.selectedMarker === marker ? 1 : 0}} 
    key={marker.id} 
    image={require('../../assets/marker-with-label/marker-with-label.png')} 
    coordinate={marker.coordinate} 
    > 
    <Text>1</Text> 
</MapView.Marker> 

回答

3

我以前做過這件事。這基本上是我做什麼,當我想自定義標記:如果你不

<MapView.Marker coordinate={marker.latlang}> 
    <View style={styles.circle}> 
    <Text style={styles.pinText}>{marker.num}</Text> 
    </View></MapView.Marker> 

樣式

circle: { 
    width: 30, 
    height: 30, 
    borderRadius: 30/2, 
    backgroundColor: 'red', 
}, 
pinText: { 
    color: 'white', 
    fontWeight: 'bold', 
    textAlign: 'center', 
    fontSize: 20, 
    marginBottom: 10, 
}, 

Example marker

+0

這隻能放大。如果您使用這種方法縮小,圓圈不會縮小。 – cbartondock