【发布时间】:2018-07-06 07:55:15
【问题描述】:
我在我的应用程序中实现了 react-google-maps 包。一切正常,但是当我在移动设备上查看网站并转到街景时,默认情况下会打开一些选项,它可以使地图随着移动设备的转动而转动。此选项默认开启。右上角有一个小移动图标,如果我按下它,它将被关闭,在街景中移动的唯一方法是用手指。 当有人进入街景时,如何将手指的这种“正常”动作设为默认?
编辑: 添加示例
import { withScriptjs, withGoogleMap, GoogleMap, Marker, InfoWindow, } from 'react-google-maps'
import Image from 'semantic-ui-react/dist/commonjs/elements/Image/Image'
class MapInfoComponent extends Component {
state = {
openInfoWindow: true,
}
onMarkerClick = () => {
this.setState(prevState => ({
openInfoWindow: !prevState.openInfoWindow,
}))
}
render() {
return (
<GoogleMap defaultZoom={10} center={{ lat: 16.4555, lng: 14.1257, }}>
<Marker position={{ lat: 16.4555, lng: 14.1257, }} onClick={this.onMarkerClick}>
{this.state.openInfoWindow && (
<InfoWindow onCloseClick={this.onMarkerClick}>
<Image src={logo} size="small" />
</InfoWindow>
)}
</Marker>
</GoogleMap>
)
}
}
const GoogleMapComponent = withGoogleMap(MapInfoComponent)
const MapComponent = withScriptjs(GoogleMapComponent)
const Maps = () => (
<div styleName="container">
<MapComponent
googleMapURL={`https://maps.googleapis.com/maps/api/js?key=${process.env.GOOGLE_MAPS ||
'addGoogleMapsKey'}&v=3.exp&libraries=geometry,drawing,places`}
loadingElement={<div style={{ height: '100%', }} />}
containerElement={<div style={{ height: '100%', }} />}
mapElement={<div style={{ height: '100%', }} />}
/>
</div>
)
export default Maps
【问题讨论】:
标签: reactjs google-maps react-google-maps