我在我的项目中使用了react-native-maps . 它工作正常 . 然后我添加了一些新组件到项目,突然当我从 Map 中删除自定义标记时,出现红色屏幕:删除标记:尝试在空对象引用上调用虚方法'void com.google.android.gms.maps.model.setIcon(com.google.android.gms.maps.model.BitmapDescription)'
您有两种选择:
First option (the easiest but will not give you the best results)
使用默认标记:
<MapView.Marker identifier="DestMarker" title={SCHEDULED_LABEL} description={this.props.region.address} coordinate={{ latitude: this.props.region.latitude, longitude: this.props.region.longitude, }} />
Second option edit react-native-maps library
去:
lib / android / src / main / java / com / airbnb / android / react / maps / AirMapMarker.java
在node_modules内部并更改此行代码
marker.setIcon(getIcon());
为了这:
if (marker != null) { marker.setIcon(getIcon()); }
你完成了!
Note: Remember to reinstall the app to see your changes
1 回答
您有两种选择:
First option (the easiest but will not give you the best results)
使用默认标记:
Second option edit react-native-maps library
去:
在node_modules内部并更改此行代码
marker.setIcon(getIcon());
为了这:
你完成了!
Note: Remember to reinstall the app to see your changes