Reactjs 标记列表在andriod上呈现,而不是在ios上呈现
我正在尝试使用react native maps在地图中呈现标记列表 我已经用Reactjs 标记列表在andriod上呈现,而不是在ios上呈现,reactjs,react-native,react-native-maps,Reactjs,React Native,React Native Maps,我正在尝试使用react native maps在地图中呈现标记列表 我已经用成功地渲染了地图,但由于某些原因,在地图上渲染标记列表时,它只会出现在android上,而不会出现在IOS上 问题是在获取数据时,因为当我尝试模拟标记数组时,它工作正常 MapviewWrapper.js: 从“React”导入React; 从“/ProvidersList”导入ProvidersList; 从“react native maps”导入MapView; 从“@ui kitten/components”导
成功地渲染了地图,但由于某些原因,在地图上渲染标记列表时,它只会出现在android上,而不会出现在IOS上
问题是在获取数据时,因为当我尝试模拟标记数组时,它工作正常
MapviewWrapper.js
:
从“React”导入React;
从“/ProvidersList”导入ProvidersList;
从“react native maps”导入MapView;
从“@ui kitten/components”导入{Layout}”;
从“react native”导入{StyleSheet,Dimensions};
从“配置”导入{mapsConfig};
常量MapviewWrapper=(道具)=>{
返回(
);
};
const styles=StyleSheet.create({
地图样式:{
宽度:尺寸。获取(“窗口”)。宽度,
高度:尺寸。获取(“窗口”)。高度,
},
});
导出默认的MapviewWrapper;
ProvidersList.js
import React,{useffect,useState}来自“React”;
从“react native maps”导入{Marker};
从“react native”导入{View};
从“配置”导入{mapsConfig};
从“api/wrappers/appService”导入{getProviders};
const getProvidersAsync=(setProviders)=>{
获取提供者({
纬度:mapsConfig.INITIAL_REGION.Latitude,
经度:mapsConfig.INITIAL_REGION.Longitude,
半径:1000,
测量单位:0,
})。然后((提供者)=>设置提供者(提供者));
};
常量提供程序列表=(道具)=>{
const[providers,setProviders]=useState([]);
useffect(()=>{
getProvidersAsync(设置提供者);
}, []);
返回(
{providers.length>0&&
providers.map((provider,id)=>(
))}
);
};
导出默认提供者列表;
问题是因为我在视图中呈现了标记列表,而不是片段
标记现在也出现在IOS上。试试这种方法
<MapView
ref={MapView => (this.MapView = MapView)}
style={styles.map}
initialRegion={this.state.region}
loadingEnabled = {true}
loadingIndicatorColor="#666666"
loadingBackgroundColor="#eeeeee"
moveOnMarkerPress = {false}
showsUserLocation={true}
showsCompass={true}
showsPointsOfInterest = {false}
provider="google">
{this.state.markers.map((marker:any) => (
<MapView.Marker
key={marker.id}
coordinate={marker.coordinate}
title={marker.title}
description={marker.description}
/>
}
</MapView>
(this.MapView=MapView)}
style={style.map}
initialRegion={this.state.region}
loadingEnabled={true}
加载指示颜色=“#666666”
loadingBackgroundColor=“#eeeeee”
moveOnMarkerPress={false}
showsUserLocation={true}
showsCompass={true}
showsPointsOfInterest={false}
provider=“谷歌”>
{this.state.markers.map((marker:any)=>(
}