react-google-maps - 如何从 react-google-maps 的 InfoWindow 中删除“关闭”按钮?
问题描述
还没有弄清楚如何做到这一点,有没有办法以 css 为目标,或者它是 lib 中的一个选项?
解决方案
根据官方文档:
该
InfoWindow
课程不提供定制。
即使可以覆盖 Google Maps API CSS以隐藏关闭按钮,例如,在这里,推荐的方法是创建一个完全自定义的弹出窗口,如果是react-google-maps
库,OverlayView
组件是一个很好的选择:
import React from "react";
import { OverlayView } from "react-google-maps";
const getPixelPositionOffset = pixelOffset => (width, height) => ({
x: -(width / 2) + pixelOffset.x,
y: -(height / 2) + pixelOffset.y
});
const Popup = props => {
return (
<OverlayView
position={props.anchorPosition}
mapPaneName={OverlayView.OVERLAY_MOUSE_TARGET}
getPixelPositionOffset={getPixelPositionOffset(props.markerPixelOffset)}
>
<div className="popup-tip-anchor">
<div className="popup-bubble-anchor">
<div className="popup-bubble-content"><h1>{props.content}</h1></div>
</div>
</div>
</OverlayView>
);
};
推荐阅读
- python - 如何在没有副作用的情况下对功能进行分组?
- javascript - 函数和对象函数有什么区别
- android - getText 在 TextView 上返回空值
- javascript - 为什么 10.333333 | 0 = 10 在 JavaScript 中?
- python - print data_frame.head 给出的输出不是一个漂亮的表
- python - OpenCV - 许可证位置检测中的误报太多
- php - Switch Case Vs Array Key Lookup,考虑到空间复杂度,后者更快
- css - Angular 5+ animate flex 在 Firefox 中不起作用
- excel - python win32错误,Microsoft Excel',
- javascript - 无法使用 Google Analytics 中的 cookie 过滤掉内部流量