【问题标题】:I have trouble with MarkerClusterer我在使用 MarkerClusterer 时遇到问题
【发布时间】:2020-12-23 08:48:21
【问题描述】:

有人可以向我解释为什么 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;

照片说明

【问题讨论】:

  • 没有照片亲爱的Conqueror135。
  • 我删除了您问题中的 API 密钥。今后请不要在公共网站上分享您的 API 密钥。

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


【解决方案1】:

我明白了!因为strictMode!当我删除它时一切都很好!

【讨论】:

    猜你喜欢
    • 2021-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多