Google 地图平移控件已显示但无法使用(在移动设备上)
Google map pan controls shown but not working (on mobile)
我需要为我的 Google 地图禁用 draggable
选项并激活平移控件,以便用户可以在移动设备上正确查看地图。所以这是我的选择:
panControl: true,
draggable: false
平移控件出现在地图上,但似乎已停用。我怎样才能激活它?我还有marker和infoWindow,不知道对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 命令。
我需要为我的 Google 地图禁用 draggable
选项并激活平移控件,以便用户可以在移动设备上正确查看地图。所以这是我的选择:
panControl: true,
draggable: false
平移控件出现在地图上,但似乎已停用。我怎样才能激活它?我还有marker和infoWindow,不知道对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 命令。