如何在React Native地图中自定义地图标记?当我单击标记时,它什么也不显示。它不显示标注组件。而且,它不允许覆盖标记样式,并且它拒绝按照我的意愿覆盖宽度和高度。
<Marker key={city.id} coordinate={{ latitude: city.latitude, longitude: city.longitude }}><View style={{width:120 , height: 30}}>Hello</View></Marker>
尝试使用
Callout
import { Callout, Marker } from "react-native-maps"
const customeIcon = require("path_to_icon");
const [selectedCity, setSelectedCity] = React.useState();
<Marker
key={city.id}
coordinate={{ latitude: city.latitude, longitude: city.longitude }}
image={customeIcon}
onPress={() => setSelectedCity(city)}
>
<Callout tooltip>
<TouchableHighlight><Text>Hello</Text></TouchableHighlight>
</Callout>
</Marker>
{ selectedCity && <YourCityDetailsComponent /> }