所以我使用react-simple-maps 来制作世界地图,但是当我单击地图时的默认行为是该国家/地区周围的蓝色矩形。preventDefault()我尝试在 an 上使用onClick,但这并不能消除它。有人对如何解决这个问题有任何想法吗?
这是我的代码。谢谢您的帮助!
import React, { Component } from "react"
import {
ComposableMap,
ZoomableGlobe,
Geographies,
Geography
} from "react-simple-maps"
import { Motion, spring } from "react-motion"
const mapStyles = {
width: "90%",
height: "auto"
}
class Map extends Component {
constructor(props) {
super(props)
this.handleClick = this.handleClick.bind(this)
}
handleClick(geography, evt) {
evt.preventDefault()
}
render() {
return (
<div>
<Motion
defaultStyle={{
x: this.props.center[0],
y: this.props.center[1]
}}
style={{
x: spring(this.props.center[0]),
y: spring(this.props.center[1])
}}
>
{({ x, y …Run Code Online (Sandbox Code Playgroud)