有人能向我解释为什么MarkerCluster在只有一个标记的情况下显示两个标记吗!这是我的代码:
const MapWithMarkerClusterer = compose(
withProps({
googleMapURL:
"https://maps.googleapis.com/maps/api/jskey=API_KEY&v=3.exp&
libraries=geometry,drawing,places",
loadingElement: <div style={{ height: `100%` }} />,
containerElement: <div style={{ height: `400px` }} />,
mapElement: <div style={{ height: `100%` }} />,
center: { lat: 25.03, lng: 121.6 },
}),
withScriptjs,
withGoogleMap
)((props) => (
<GoogleMap
defaultZoom={10}
defaultCenter={{ lat: 19.807151, lng: 105.795327 }}
>
<MarkerClusterer averageCenter enableRetinaIcons gridSize={100}>
<Marker
position={{
lat: 19.807151,
lng: 105.795327,
}}
/>
</MarkerClusterer>
</GoogleMap>
));
export default MapWithMarkerClusterer;
照片描述
我搞定了!因为strictMode!删除时一切都很好!