我已經在我的 react 應用程式中使用 react-google-maps/app 設定了一個地圖,但是有些事情讓我很煩。要使用滾輪縮放地圖,您必須按住控制鍵。有沒有辦法可以禁用它,以便我可以在不控制的情況下進行縮放。有沒有辦法做到這一點?
這是我的地圖代碼:
class MapContainer extends React.Component {
render() {
return (
<>
<LoadScript googleMapsApiKey="API-KEY" >
<GoogleMap
zoom={14}
mapContainerStyle={{width: window.innerWidth, height: window.innerHeight}}
// Using placeholder lat/lng coords here, they're real in my actual code
center={{
lat: 0.00000000,
lng: 0.00000000
}}
onClick={(e) => {console.log(`${e.latLng.lat()} ${e.latLng.lng()}`)}}
>
</GoogleMap>
</LoadScript>
</>
)
}
}
uj5u.com熱心網友回復:
在查看了 google maps javascript API 的檔案后,我發現您可以使用optionsGoogleMap 組件的 prop 執行此操作,并將其設定gestureHandling為greedy,如下所示:
<GoogleMap
options={{
gestureHandling: "greedy"
}}
>
</GoogleMap>
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/477137.html
標籤:javascript 反应 谷歌地图 反应谷歌地图 API
