0
我之前有過類似的問題,但是由於id導致死路一條,而且我現在對不同觀點已經形成了新的理解。我現在的問題是如何與媒體查詢和panBy與偏移量,而不是處理,這是新計算出的每調整調整大小時的響應偏移量(panBy)。谷歌地圖
我用這個代碼(更新):
var map;
function initialize() {
var Name = {lat: XX, lng: XX};
var marker = new google.maps.Marker({
position: Name,
map: map,
title: 'Name!'
});
var mapOptions = {
center: new google.maps.LatLng(XX, XX),
zoom: 13,
zoomControl: false,
disableDoubleClickZoom: false,
mapTypeControl: false,
scaleControl: false,
scrollwheel: false,
panControl: false,
streetViewControl: false,
draggable: false,
overviewMapControl: false,
overviewMapControlOptions: {
opened: false,
},
mapTypeId: google.maps.MapTypeId.ROADMAP,
styles: styleArray
};
map = new google.maps.Map(document.getElementById("map"),
mapOptions);
marker = new google.maps.Marker({
icon: markericon,
position: new google.maps.LatLng(locations[i][5], locations[i][6]),
map: map,
title: locations[i][0],
desc: description,
tel: telephone,
email: email,
web: web
});
}
var mql = window.matchMedia(("(max-height: 750px)"));
mql.addListener(new function(){
if(window.matchMedia("(max-height: 750px)").matches){
map.panBy(0, 150);
}else {
map.panBy(0, 250);
}});
}
google.maps.event.addDomListener(window, 'load', initialize);
google.maps.event.addDomListener(window, "resize", function() {
var center = map.getCenter();
google.maps.event.trigger(map, "resize");
map.setCenter(center);
});
感謝您的閱讀! Regards
以及我的腳本完全看起來完全像我從這個頁面得到它,但我仍然無法弄清楚如何應用每個調整大小新計算的偏移量。 – TheWeeezel