volga-volga / react-native-yamap

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

Android: Не срабатывает onPress маркера в ClusteredYamap #293

Open mvpk-x opened 2 months ago

mvpk-x commented 2 months ago
import React from 'react';
import { ClusteredYamap } from '../../react-native-yamap/src';

const Map = () => {
  return (
    <ClusteredYamap
      clusterColor="red"
      clusteredMarkers={[
        {
          point: {
            lat: 56.754215,
            lon: 38.622504,
          },
          data: {},
        },
        {
          point: {
            lat: 56.754215,
            lon: 38.222504,
          },
          data: {},
        },
      ]}
      renderMarker={(info, index) => (
        <Marker
          key={index}
          point={info.point}
          onPress={() => console.log('pressed')}
        />
      )}
      style={{flex: 1}}
    />
  );
};

На iOS не проверял.

ybalaev1 commented 2 months ago

на ios тоже не работает нажатие на маркер😔 "react-native-yamap": "^4.6.0", сделал костыль - работает через раз, т.к точность 1:100 точек в функции onMapPress

const pLat = e.nativeEvent.lat;
            const pLon = e.nativeEvent.lon;
            // вычисление погрешности при нажатии на карту и сравнивание с координатами активности(Math.abs(pLon - activity.location.coordinates.longitude) >= 0.001));
            const item = activities.find(activity => {
              const dep = Math.abs(pLat - activity.location.coordinates.latitude) >= 0.001;
              const depLon = Math.abs(pLon - activity.location.coordinates.longitude) >= 0.001;Math.abs(pLon - 
              activity.location.coordinates.longitude), depLon);

              if (!dep && !depLon) {
                return activity;
              }
            });

            if (!!item) {
              onPresItem(item);
            }
DMilyutin commented 1 month ago

на ios тоже не работает нажатие на маркер😔 "react-native-yamap": "^4.6.0", сделал костыль - работает через раз, т.к точность 1:100 точек в функции onMapPress

const pLat = e.nativeEvent.lat;
            const pLon = e.nativeEvent.lon;
            // вычисление погрешности при нажатии на карту и сравнивание с координатами активности(Math.abs(pLon - activity.location.coordinates.longitude) >= 0.001));
            const item = activities.find(activity => {
              const dep = Math.abs(pLat - activity.location.coordinates.latitude) >= 0.001;
              const depLon = Math.abs(pLon - activity.location.coordinates.longitude) >= 0.001;Math.abs(pLon - 
              activity.location.coordinates.longitude), depLon);

              if (!dep && !depLon) {
                return activity;
              }
            });

            if (!!item) {
              onPresItem(item);
            }

На iOS работает нажатие на маркер