简体   繁体   English

如何突出显示这样的本机地图?

[英]How to hightlight a react-native map like that?

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

It's called Polygon . 这就是Polygon

  1. You need to provide the coordinates of the area that you want to highlight. 您需要提供要突出显示的区域的坐标。

  2. Put all coordinates in an array. 将所有坐标放入数组中。

  3. A coordinate will be connect to its previous coordinate with a straight line. 坐标将通过一条直线连接到其先前的坐标。 In case of the image you posted, you need a looooot of coordinates. 如果您发布的是图片,则需要使用一些坐标。 I personally don't know any public API that returns an array of coordinates of desired area, but I'm sure there is one, just google it. 我个人不知道任何公共API返回所需区域的坐标数组,但是我敢肯定有一个,只是用谷歌搜索即可。

Once you have the coordinates in an array, use them like this in your MapView : 将坐标放置在数组中后,可在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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM