У указанного ребенка уже есть родитель. Вы должны вызвать removeView () на родительском элементе ребенка, чтобы сначала реагировать на нативный - PullRequest
0 голосов
/ 11 ноября 2019

Я хочу использовать маркер внутри MapView. Каждый раз, когда я хочу загрузить, я сталкиваюсь с этой ошибкой. Любая помощь будет оценена.

У меня есть несколько решений. Но для моего случая это не помогло.

import React, { Component } from "react";

import MapView, { Polyline } from "react-native-maps";

<View style={StyleSheet.absoluteFillObject}>
  <MapView
    showsUserLocation //to show user current location when given access
    loadingEnabled //to show loading while map loading
    style={styles.map}
    initialRegion={{
      // latitude : 27.6937681,
      latitude,
      // longitude : 85.3216398,
      longitude,
      latitudeDelta: 0.0922,
      longitudeDelta: 0.0421
    }}
  >
    <>
      {locations &&
        locations.map((location, index) => {
          const {
            coords: { latitude, longitude }
          } = location;
          return (
            <Marker
              key={index}
              coordinate={{ latitude, longitude }}
              // onPress={this.onMarkerPress(location)}
            />
          );
        })}

      <Polyline strokeWidth={2} strokeColor="red" coordinates={coords} />
    </>
  </MapView>
</View>

Я хочу отрисовать маркер без ошибок.

Вот мои используемые зависимости:

"dependencies": {
    "native-base": "^2.13.8",
    "react": "16.9.0",
    "react-native": "0.61.2",
    "react-native-maps": "git+https://git@github.com/react-native-community/react-native-maps.git"
}```
...