【发布时间】:2017-06-16 07:29:07
【问题描述】:
在 GitHub 上的 react-native-maps 存储库的示例中提供的示例显示了一个按钮,用于执行一个功能来设置考虑到标记列表的适当缩放:
fitAllMarkers() {
this.map.fitToCoordinates(MARKERS, {
edgePadding: DEFAULT_PADDING,
animated: true,
});
}
https://github.com/airbnb/react-native-maps/blob/master/docs/mapview.md
如果给定一个已经初始化的标记数组,是否可以用适当的拟合来初始化地图?
当尝试在componentDidMount 上设置合适的尺寸时,我收到:
Error using new LatLntBounds(LatLngBounds, int): Map size can't be 0. Most likely, layout has not yet occured for the map view.
现在调用我的fitAllMarkers() 函数绝对为时过早。
有没有onLoad函数可以在地图初始化后立即触发?
【问题讨论】:
标签: javascript android google-maps react-native react-native-maps