• Resolved flowbob

    (@flowbob)


    I’m searching for a convenient way to set the mapOption draggable to false on mobile.
    It’d be cool if the map object would be initialized as a property of window, so it would be accessible from anywhere like:

    window.map = new google.maps.Map(..)

    Or is there another way to do this?

    Any help appreciated.

    https://wordpress.org/plugins/wp-store-locator/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Tijmen Smit

    (@tijmensmit)

    The only way to do that at the moment is by adding code like this the wpsl-gmap.js file just below the myOptions var.

    if ( checkMobileUserAgent() ) {
       myOptions.draggable = false;
    }

    Not sure if this is a very user friendly thing to disable on a mobile device? But maybe I will make this an option in a future update, so that you can enable it from the settings page.

    Thread Starter flowbob

    (@flowbob)

    i patched it for the time being by adding this:

    var mobileMapOptions = {
        draggable: false,
        scrollwheel: false
    }
    var desktopMapOptions = {
        draggable: true,
        scrollwheel: true
    }
    var minDraggableWidth = 769;
    google.maps.event.addDomListener(window, "resize", function() {
        if (document.body.clientWidth < minDraggableWidth) {
            map.setOptions(mobileMapOptions);
        } else{
            map.setOptions(desktopMapOptions);
        }
    });

    I don’t really like this solution, as it gets lost after each plugin update..
    Is there a repository i can contribute to? I’d add the necessary changes if you like.

    The whole reason behind this is, that users on mobile devices will only scroll the map and not the site when reaching the storefinder. The only way (i’m aware) to prevent this is to set draggable to false.

    Thank’s for the support and the plugin either way 😉

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘draggable=false on mobile’ is closed to new replies.