volga-volga / react-native-yamap

React Native Yandex Maps | Яндекс Карты | Yandex.MapKit implementation for react native | YandexMaps
144 stars 80 forks source link

Кнопки поверх карты? #222

Closed J9s3s closed 1 year ago

J9s3s commented 1 year ago

Здравствуйте, как можно сделать кнопки поверх карты, которые будут перенаправлять на другой экран? Кнопки сделать получается, но метод onPress не срабатывает.

    <View style={{
      width: 100,
      height: 100,
      marginTop: 70,
      marginLeft: 55
    }}
    >
    <Button title="Профиль" onPress={() => navigation.navigate('Account')}></Button>
    </View>

image

algokano commented 1 year ago

Hello, I think the code bellow will help you @J9s3s

<View style={{flex: 1}}> <YaMap initialRegion={{ lat: 41.27417, lon: 69.15908, zoom: 10, azimuth: 80, tilt: 100, }} style={{flex: 1}} /> <View style={{ zIndex: 1, position: 'absolute', width: 100, height: 100, top: 70, left: 55, }}> <Button title="Профиль" onPress={() => { console.log('pressed'); }} /> </View> </View>

ownikss commented 1 year ago

В вопросе не увидел где именно рендерится карта.

В примере из readme кнопки отображаются поверх карты. Файл с рендером - https://github.com/ownikss/rn-yamaps-example/blob/master/app/App.tsx

Если кратко, то примерно так:

<View>
  <YaMap/>
  <View style={{ position: 'absolute', ... }}>
    <Button />
  </View>
</View>