MapView.Polyline 在本机与 expo 反应中抛出错误(我正在使用 android 进行测试)

Raf*_*ael 0 android-mapview reactjs react-native

I\xe2\x80\x99m 尝试用折线绘制一条线,但 I\xe2\x80\x99m 收到此错误:

\n

更新由 AIRMapPolyline\nnull\n管理的视图的属性 \xe2\x80\x98lineCap\xe2\x80\x99 时出错:尝试调用虚拟方法 \xe2\x80\x98void com.google.android.gms.maps.model.. ug(java.util.List) 对空对象引用

\n

这是代码:

\n
           <MapView\n                style={styles.map}\n                initialRegion={{\n                    latitude: initialLocation.latitude,\n                    longitude: initialLocation.longitude,\n                    latitudeDelta: 0.01,\n                    longitudeDelta: 0.01\n                }}\n            >\n                <Circle\n                    center={currentLocation.coords}\n                    radius={30}\n                    strokeColor=\'rgba(158, 158, 255, 1.0)\'\n                    fillColor=\'rgba(0, 0, 255, 0.3)\'\n                />\n                {drawLine && (\n                    <MapView.Polyline\n                        coordinates={locations.map(loc => {\n                            return {\n                                latitude: loc.coords.latitude,\n                                longitude: loc.coords.longitude\n                            };\n                        })}\n                        strokeColor=\'red\'\n                        strokeWidth={1}\n                    />\n                )}\n            </MapView>\n\n
Run Code Online (Sandbox Code Playgroud)\n

地图绘制正常,圆圈显示正常,但是当我尝试绘制一条线时,它会抛出可怕的错误。

\n

对象数组已被检查

\n

在此输入图像描述 在此输入图像描述

\n

https://github.com/rafaelsoteldosilva/maptest

\n

会是什么呢?

\n

拉斐尔

\n

Hug*_*oua 5

您需要做的就是添加:

lineDashPattern={[1]}
Run Code Online (Sandbox Code Playgroud)

作为 Polyline 组件的属性,例如:

<Polyline
   style={{}}
   coordinates={route}
   strokeColor={#000}
   strokeWidth={3}
   lineDashPattern={[1]}
/>
Run Code Online (Sandbox Code Playgroud)

你应该可以走了