Quantcast
Viewing all articles
Browse latest Browse all 22091

landwire on "[Plugin: Leaflet Maps Marker (Google Maps, OpenStreetMap, Bing Maps)] disable 'draggable' only on mobile devices"

Ok, went down a different route. Here is a little script that will check the size of browser window and then change the mapsize to 90% (so people can still use their fingers to scroll past the map). It will change back to 100% when the window becomes bigger than 640px. Maybe it will come in useful to somebody.

Likely it could still be improved, but it works in my case. I just added the on resize to test it on my desktop.

// script to resize mapsmarker maps on screen resolutions or window resize smaller then 640px
jQuery(function(){
	var windowWidth = jQuery(window).width();
	if (windowWidth <= 640) {
		jQuery('div.mapsmarker').css({
            	'width' 		: '90%',
            	'margin-left' 	: 'auto',
            	'margin-right' 	: 'auto'
     	});
    }
	jQuery(window).on('resize', function(){
    	var win = jQuery(this); //this = window
    	if (win.width() <= 640) {
       		jQuery('div.mapsmarker').css({
            	'width' 		: '90%',
            	'margin-left' 	: 'auto',
            	'margin-right' 	: 'auto'
     		});
        }
		else {
			jQuery('div.mapsmarker').css({
				'width' 		: '100%'
     		});
		}
    });
});

Viewing all articles
Browse latest Browse all 22091

Trending Articles