我在MarkerClusterer上遇到麻烦

时间:2020-09-04 04:59:21

标签: javascript reactjs google-maps react-google-maps

有人可以向我解释为什么只有一个标记时MarkerClusterer会显示2个标记! 这是我的代码:

   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;

照片说明

1 个答案:

答案 0 :(得分:0)

我明白了!因为strictMode!删除后一切都很好!