Answer the question
In order to leave comments, you need to log in
Draggable in google maps, turning it off under certain conditions?
In general, such a disaster: there is a map that has draggable set to true. Everything works great, no problems. But when visiting the site on a mobile device, wild map lags occur, and the phone starts to lag (not everyone has iOS). Is it possible to somehow make it so that when the screen resolution is 640px, the draggable value is set to false? In general, so that at a resolution> 640px the map does not move?
$(function() {
function initialize() {
var myLatlng = new google.maps.LatLng(56.293575, 43.94863);
var mapOptions = {
zoom: 15,
disableDefaultUI: true,
scrollwheel: false,
draggable: false,
center: myLatlng,
zoomControl: true
};
var map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
var contentString = '<div id="map-content">' +
'<div>д.10 оф.35-36 </div>'
'</div>';
var infowindow = new google.maps.InfoWindow({
content: contentString
});
var marker = new google.maps.Marker({
position: map.getCenter(),
icon: {
path: google.maps.SymbolPath.CIRCLE,
scale: 10
},
map: map
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
}
google.maps.event.addDomListener(window, 'load', initialize);
})
Answer the question
In order to leave comments, you need to log in
When initializing the map, as a value for the "draggable" parameter, you can substitute the result of comparing the screen width with any value. For example, like this:
var mapOptions = {
draggable: $(window).width() > 640,
//... Остальные опции
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question