我需要为我的谷歌地图禁用draggable
选项并激活平移控件,以便用户可以在移动设备上正确查看地图。下面是我的选项:
panControl: true,
draggable: false
Pan控件出现在地图上,但似乎已停用。我如何激活它?我也有标记和信息窗口,我不知道它是否影响平移,所以这里有完整的地图代码:
function initMap() {
var latLng = new google.maps.LatLng( myloc , myloc ),
options = {
zoom: 15,
center: latLng,
panControl: true,
draggable: false,
zoomControl: true,
streetViewControl: !1,
mapTypeControl: !1,
scrollwheel: !1,
},
mapContainer = document.getElementById("map"),
map = new google.maps.Map(mapContainer, options),
marker = new google.maps.Marker({
position: latLng,
map: map,
icon: "/img/map-marker.png"
}),
infoWindowContent = '<div class="infowindow">My Info</div>',
infoWindow = new google.maps.InfoWindow({
content: infoWindowContent
});
infoWindow.open(map, marker), google.maps.event.addListener(marker, "click", function() {
infoWindow.open(map, marker)
}), google.maps.event.addDomListener(window, "resize", function() {
map.setCenter(latLng)
});
}
$(document).on('touchstart', 'div[title*=Mover]', function () {
$(this).trigger('click');
return false;
});
将"Mover"改为"Pan",或者根据你在GMaps脚本中使用的语言将"Pan"命令命名为任何名称