How can I disable scrolling on the Google Maps mobile layout?

后端 未结 8 2127
广开言路
广开言路 2020-12-08 07:07

I am developing mobile sites with Google Maps embedded via the Google Maps API. I have been able to stop certain types of behavior but have been unable to find a good way to

8条回答
  •  忘掉有多难
    2020-12-08 07:46

    You can also try a) a server side mobile detection liked mentioned here and then b) include it in your .php (e.g. header.php or footer.php) file, like so:

    function isMobile() {
        return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]);
    }
    

    Embed it in your code:

    var mapOptions = {
            zoom: 18,
            center: new google.maps.LatLng(12.345, 12.345),
            scrollwheel: false,
            
        };
    

    Note that this of course only works if you have Google Maps Javascript code embedded in your php file.

提交回复
热议问题