我有一个react native移动应用程序并使用react native maps,我想在应用程序开始时加载标记,但是我得到了
latlng cannot be null - a position is required
错误。
我要做的是填充数组标记
export default class MapScreen extends React.Component {
constructor(props) {
super(props);
this.watchID = navigator.geolocation.watchPosition((position) => {
console.log(position.coords) // get your showUserLocation here
},
(error) => console.log(error.message), GEOLOCATION_SETTINGS
)
this.state = {
region: {
latitude: LATITUDE,
longitude: LONGITUDE,
latitudeDelta: LATITUDE_DELTA,
longitudeDelta: LONGITUDE_DELTA,
},
markers: [{
title: 'FINISH',
description: 'You have found me!',
coordinates: {
latitude: 14.548100,
longitude: 121.049906
},
}]
}
}
稍后再调用:
{this.state.markers.map(marker => (
<Marker
key={marker.key}
coordinate={marker.coordinate}
pinColor={marker.color}
>
{/* Callout est l'infowindow */}
<Callout style={styles.plainView}>
<View>
{/* Texte par défaut pour le moment, à changer (voir ticket MARKER3) */}
<Text>
Nom + Coordonnées + click here to see info
</Text>
</View>
</Callout>
</Marker>
))}
我想我是以这种方式提供信息的
markers[]
是错的,但我尽了我所能,包括
markers: [{
latlng: {
latitude: 14.548100,
longitude: 121.049906
},
}]
它仍然告诉我latlng是空的。
问题真的是输入语法吗?我怎样才能找到正确的那个?