如何高亮显示反应原生地图?

时间:2018-05-01 17:51:20

标签: javascript reactjs react-native react-native-maps

我正在使用react-native-maps库来显示地图,但是如何突出显示这个截图的区域?

1 个答案:

答案 0 :(得分:0)

它被称为Polygon

  1. 您需要提供要突出显示的区域的坐标。

  2. 将所有坐标放在数组中。

  3. 坐标将以直线连接到其先前的坐标。如果您发布的图像,您需要一个looooot坐标。我个人不知道任何公共API返回所需区域的坐标数组,但我确定有一个,只是google它。

  4. 在数组中有坐标后,请在MapView

    中使用它们
    <MapView>
        <MapView.Polygon
            coordinates={[
                { latitude: 123, longitude: 123 },
                { latitude: 124, longitude: 124 },
                ...
            ]}
            strokeWidth={1}        // The width of the outline of the shape
            strokeColor='#4099FF'  // Color of the outline
            fillColor='rgba(...)'  // Shape color
        />
    </MapView>