簡體   English   中英

react-google-maps/api 刪除需要按住 ctrl 來縮放

[英]react-google-maps/api Remove need to hold ctrl to zoom

我在我的 React 應用程序中使用 react-google-maps/app 設置了一個 map,但有些事情讓我很煩。 要使用滾輪縮放 map,您必須按住控制鍵。 有沒有一種方法可以禁用它,這樣我就可以在不控制的情況下進行縮放。 有沒有辦法做到這一點?

這是我的 map 的代碼:

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>
            </>
        )
    }
}

在查看了 google maps javascript API 的文檔后,我發現您可以使用 GoogleMap 組件的options屬性並將gestureHandling設置為greedy來執行此操作,如下所示:

<GoogleMap
    options={{
        gestureHandling: "greedy"
    }}
>
</GoogleMap>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM