小编rap*_*aph的帖子

“在Android上使用react-native-maps使用newLatLngBounds(LatLngBounds,int)时出错:地图大小不能为零...。”

我收到一个错误:“使用newLatLngBounds(LatLngBounds,int)时出错:地图大小不能为零。最有可能的布局尚未出现在地图视图中。要么等待布局发生,要么使用newLatLngBounds(LatLngBounds(LatLngBounds,int,int) ,int),它允许您指定地图的尺寸​​”。

但是我为getCurrentPosition设置了警报,并且正在从getCurrentPosition()接收坐标。

import React, { Component } from 'react';
import { View, Dimensions } from 'react-native';
import MapView from 'react-native-maps';


const {width, height} = Dimensions.get('window')

const SCREEN_HEIGHT = height
const SCREEN_WIDTH = width
const ASPECT_RATIO = width / height
const LATITUDE_DELTA = 0.0922
const LONGITUDE_DELTA = LATITUDE_DELTA * ASPECT_RATIO


class Map extends Component {
	
	constructor(props) {
		super(props)

		this.state = {
			isMapReady: false,
			initialPosition: {
				longitude: 0,
				latitude: 0,
				longitudeDelta: 0,
				latitudeDelta: 0
			},

			markerPosition: {
				longitude: 0,
				latitude: 0 …
Run Code Online (Sandbox Code Playgroud)

android reactjs react-native react-native-android react-native-maps

6
推荐指数
3
解决办法
5095
查看次数