Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native React本机图像映射器(如何在图像上创建可触摸区域)_React Native - Fatal编程技术网

React native React本机图像映射器(如何在图像上创建可触摸区域)

React native React本机图像映射器(如何在图像上创建可触摸区域),react-native,React Native,如何在图像上创建可触摸区域[单击位置1显示效果,在另一个位置2、3、4、5上显示相同效果和不同效果。] 实际上,当我点击图像上的特定位置时,会得到相应的x和y坐标,但不会得到图像上的可触摸区域 我们必须创建一个与此类似的映射对象 const MAPPING = [ { id: '0', name: 'First Area Name', shape: 'rectangle', width: 30, height: 40, x1: 80,

如何在图像上创建可触摸区域[单击位置1显示效果,在另一个位置2、3、4、5上显示相同效果和不同效果。]

实际上,当我点击图像上的特定位置时,会得到相应的x和y坐标,但不会得到图像上的可触摸区域

我们必须创建一个与此类似的映射对象

    const MAPPING = [
  {
    id: '0',
    name: 'First Area Name',
    shape: 'rectangle',
    width: 30,
    height: 40,
    x1: 80,
    y1: 500,
    prefill: 'red',
    fill: 'blue'
  },
  {
    id: '1',
    name: 'Second Area Name',
    shape: 'rectangle',
    x2: 155,
    y2: 540,
    x1: 125,
    y1: 500
  },
]
图像映射器的使用

 <ImageMapper
        imgHeight={500}
        imgWidth={250}
        imgSource={imageSource}
        imgMap={MAPPING}
        onPress={(item, idx, event) => this.onAnyAreaPress(item, idx, event)}
        containerStyle={styles.myCustomStyle}
        selectedAreaId="my_area_id"
      />
this.onAnyAreaPress(item,idx,event)}
containerStyle={styles.myCustomStyle}
selectedreaid=“我的\u区域\u id”
/>
它根据我们通过的映射提供了接触点。 请查看此文档以了解更多信息。