Google Maps - SCROLL/Draggable on mobiles on TOUCH/CLICK

Hi guys,

I have a problem… i don’t know how to create a option that… when you are on small devices that when you TOUCH
the map… that makes it scroll/draggable ONLY. Now it’s not dragging at all… on mobile devices.

How can i make this on click?

My code:

Can somebody please help me?

			disableDrag = function (){
					var isDraggable = !('ontouchstart' in document.documentElement);
					var mapOptions = {
						draggable: isDraggable,
						scrollwheel: false
					};					
			},
    initMap = function() {
				var isDraggable = !('ontouchstart' in document.documentElement);
        that.map = new google.maps.Map(document.getElementById('map'), {
            center: center,
            zoom: defaultZoom,
							draggable: isDraggable,
            disableDefaultUI: true,
            scrollwheel: false,
            styles: getMapStyle(mapStyle)
        });
        google.maps.event.addListener(that.map, 'zoom_changed', zoom_changed_event);
        google.maps.event.addListenerOnce(that.map, 'idle', idleEvent);
        dom.on(window, 'resize', resizeMap);
    },

the disabledDrag doesn’t appear to be doing anything useful.

Looks like you just need to remore the ! from here var isDraggable = ('ontouchstart' in document.documentElement);

Hi,

I have removed ! but still the not working any ideas?

Try this

that.map = new google.maps.Map(document.getElementById('map'), {
  center: center,
  zoom: defaultZoom,
  draggable: true,
  disableDefaultUI: true,
  scrollwheel: false,
  styles: getMapStyle(mapStyle)
});

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.