如何在 ios 地图上以 react-native 推送多个标记字典

How Do I push multiple marker a dictionary in react-native on ios map

大家刚学js配合react-native,为什么我可以push in setstate?总有 "syntaxerror unexpected token".

getInitialState () {
  return {
    marker : []
  };
},

fetch('http://www.mywebsite.search.php')
  .then((response) => response.json())
  .then((responseData) => {
    console.log('Fetch Success');
    console.log(responseData);

    this.setState({ marker: [] });

    for (var p in responseData) {
      this.setState({
        // marker.push({
        // latitude: responseData[p]['lat'],
        // longitude: responseData[p]['lng']
        //})
      });
    }
  })
  .catch((error) => {
    console.warn(error);
  })
  .done();

解决。谢谢卡帕!

fetch('http://www.mywebsite.search.php')
  .then((response) => response.json())
  .then((responseData) => {
    console.log('Fetch Success');
    console.log(responseData);

    var tempMarker = [];
    for (var p in responseData) {
      tempMarker.push({
        latitude: responseData[p]['lat'],
        longitude: responseData[p]['lng'],
      });
    }

    this.setState({
      marker: tempMarker,
    });
  })
  .catch((error) => {
    console.warn(error);
  })
  .done();