Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 以位置为中心渲染谷歌地图覆盖视图_Reactjs_Google Maps_Google Maps Markers_React Google Maps - Fatal编程技术网

Reactjs 以位置为中心渲染谷歌地图覆盖视图

Reactjs 以位置为中心渲染谷歌地图覆盖视图,reactjs,google-maps,google-maps-markers,react-google-maps,Reactjs,Google Maps,Google Maps Markers,React Google Maps,我需要渲染一个位于特定位置中心的按钮,现在我正在使用OverlayView渲染按钮 <OverlayView position={north} mapPaneName={OverlayView.OVERLAY_MOUSE_TARGET} > <MapContextButton onClick={e => { e.preventDefault(); console.l

我需要渲染一个位于特定位置中心的按钮,现在我正在使用OverlayView渲染按钮

    <OverlayView
      position={north}
      mapPaneName={OverlayView.OVERLAY_MOUSE_TARGET}
    >
      <MapContextButton
        onClick={e => {
          e.preventDefault();
          console.log('click');
        }}
      />
    </OverlayView>

{
e、 预防默认值();
console.log('click');
}}
/>
它生成以下结果,渲染覆盖在北点上的左上角位置。有没有办法使它以位置为中心渲染


我可以通过为图标设置锚定位置的标记来解决这个问题

          <Marker
            position={north}
            icon={{
              url: MapContextIcon,
              anchor: new window.google.maps.Point(16, 16),
            }}
            onClick={() => {
              setIsPopoverOpen(!isPopoverOpen);
            }}
          />
{
setIsPopoverOpen(!isPopoverOpen);
}}
/>

我可以通过为图标设置锚定位置的标记来解决这个问题

          <Marker
            position={north}
            icon={{
              url: MapContextIcon,
              anchor: new window.google.maps.Point(16, 16),
            }}
            onClick={() => {
              setIsPopoverOpen(!isPopoverOpen);
            }}
          />
{
setIsPopoverOpen(!isPopoverOpen);
}}
/>