reactjs - 将光标更改为指针 google-maps-react

标签 reactjs react-google-maps

我正在使用google-maps-react 。默认情况下,当我将鼠标放在 map 上时,它会显示手形光标。我想当人悬停在 map 上时设置一个普通指针,并且只有当开始拖动时,光标再次变成手形光标。

我尝试以多种方式设置 draggableCursos 属性,但没有得到我想要的。

感谢您提前提供的帮助。

最佳答案

npm 中发布的 google-maps-react 包的当前版本 (2.0.2) 似乎不支持指定一些属性,包括 MapOptions.draggableCursorMapOptions.draggingCursor通过 map 组件。在这种情况下,可以通过 native map 对象指定这些属性。下面的例子演示了它

class MapContainer extends React.Component {
  constructor(props) {
    super(props);
    this.handleMapReady = this.handleMapReady.bind(this);
  }

  handleMapReady(mapProps,map) {
    map.setOptions({
      draggableCursor: "default",
      draggingCursor: "pointer"
    });
  }



  render() {
    return (
      <div className="map-container">
        <Map
          google={this.props.google}
          className={"map"}
          zoom={this.props.zoom}
          initialCenter={this.props.center}
          onReady={this.handleMapReady}
        />
      </div>
    );
  }
}

Here is a demo

关于reactjs - 将光标更改为指针 google-maps-react,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54723435/

相关文章:

css - 我怎样才能将我的按钮向上移动,因为文本是

ios - 为什么 React Native iOS 模拟器的重新加载快捷方式有时会停止工作?

css - 如何上下滚动边栏而不是整个窗口?

javascript - 使用 Google map 将用户限制为一次只能访问一个多边形

angularjs - 蓝点表示 react 谷歌地图中的当前位置

reactjs - 多边形没有出现在react-google-maps中

javascript - ReactJS 中的多个下拉菜单,一次只能打开一个

reactjs - 当我通过列表映射时,React-bootstrap Modal 组件打开/关闭所有模式

javascript - react-google-maps 在用户提交后呈现标记

google-maps-api-3 - 在 react-google-maps 中动态添加、更新、删除标记