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\nRun Code Online (Sandbox Code Playgroud)\n地图绘制正常,圆圈显示正常,但是当我尝试绘制一条线时,它会抛出可怕的错误。
\n对象数组已被检查
\n\nhttps://github.com/rafaelsoteldosilva/maptest
\n会是什么呢?
\n拉斐尔
\n您需要做的就是添加:
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)
你应该可以走了
| 归档时间: |
|
| 查看次数: |
1498 次 |
| 最近记录: |