在 Android 上渲染一组标记,但在 iOS 上则不渲染。 当我传递单个标记时,这确实有效,但数组无法显示。
它可以在 iOS 上的 expo 应用程序中运行,但是当我将其发布到 testflight 时,它停止工作。
“react-native-maps”:“1.3.2” “博览会”:“^47.0.0”
我的组件代码是:
const MapV2 = ({location, style, markers, title, coordinate, onPress, selectedStation}) => {
const mapRef = useRef(null);
const [mapReady, setMapReady] = useState(false);
const onRegionChangeComplete = (currentRegion) => {};
return (
<MapView
ref={mapRef}
onMapReady={() => {
setTimeout(() => setMapReady(true), 1000)
}}
style={style}
initialRegion={{
...location,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}}
onRegionChangeComplete={(currentRegion) => {
onRegionChangeComplete(currentRegion);
}}
showsUserLocation
showsMyLocationButton={false}
provider={PROVIDER_GOOGLE}
customMapStyle={...}
>
{markers?.map((m, index) => {
return (
<Marker
key={index}
coordinate={m.coordinate}
onPress={m.onPress}
tracksViewChanges={!mapReady}
image={
selectedStation?.id == m.item.id
? petrol_on
: m.homeStation
? petrol_home
: petrol_off
}
/>
);
})}
{title && (
<Marker
key={"1"}
title={title}
coordinate={coordinate}
onPress={onPress}
image={petrol_on}
/>
)}
</MapView>
);
}
我已经实现了编写的解决方案:https://github.com/react-native-maps/react-native-maps/issues/3384但没有运气
我已经尝试过https://github.com/venits/react-native-map-clustering/issues/237
尝试了功能性和非功能性组件,但结果相同。
向标记添加了 zIndex。
我遇到了同样的问题,我按如下方式导入标记(并且没有收到任何错误):
import Marker from 'react-native-maps';
我将其更改如下,标记开始出现。
import { Marker } from 'react-native-maps';
我希望这有帮助:)