小编Jar*_*udd的帖子

使用 newLatLngBounds(LatLngBounds, int) 时出错:地图大小不能为 0。很可能,地图视图尚未进行布局

在 android 上使用 react-native-maps 渲染地图时,我偶尔会在 Firebase 顾问中遇到此错误。在渲染 MapView 之前,我检查了是否有纬度和经度。但是我在某处遗漏了一些东西。任何帮助是极大的赞赏。下面是我的 Map 组件的代码。

import React, { Component } from 'react';
import { View, TouchableOpacity } from 'react-native';
import MapView, { PROVIDER_GOOGLE } from 'react-native-maps';
import Icon from 'react-native-vector-icons/MaterialIcons';

const renderMarker = ({withMarker, onPress}) =>{

  const { overlayStyle } = styles;
  if(withMarker){
    if(onPress){
      return (
        <TouchableOpacity
          onPress={onPress}
          style={overlayStyle}>
          <Icon
            pointerEvents="none"
            style={{
              marginBottom:32,
              width: 40,
                height:40
            }}
            allowFontScaling={false}
            color="#31cce5"
            name="place"
            size={44}
          />
        </TouchableOpacity>
      );
    }else{
      return(
        <View
          pointerEvents={"none"}
          style={overlayStyle}>
          <Icon
            pointerEvents="none"
            style={{
              marginBottom:32,
              width: …
Run Code Online (Sandbox Code Playgroud)

android reactjs react-native react-native-maps

5
推荐指数
0
解决办法
2941
查看次数