マップに カスタム ズーム ボタンを作成することで、この問題を解決しました。
これが私のプロジェクトのコードです:
編集:不要で自明の共通コードを削除し ました
あなたの zoomControl 関数:
function zoomControl(map, div) {
var controlDiv = div,
control = this;
// Set styles to your own pa DIV
controlDiv.style.padding = '5px';
// Set CSS for the zoom in div.
var zoomIncrease = document.createElement('div');
zoomIncrease.title = 'Click to zoom in';
// etc.
// Set CSS for the zoom in interior.
var zoomIncreaseText = document.createElement('div');
// Use custom image
zoomIncreaseText.innerHTML = '<strong><img src="./images/plusBut.png" width="30px" height="30px"/></strong>';
zoomIncrease.appendChild(zoomIncreaseText);
// Set CSS for the zoom out div, in asimilar way
var zoomDecreaseText = document.createElement('div');
// .. Code .. Similar to above
// Set CSS for the zoom out interior.
// .. Code ..
// Setup the click event listener for Zoom Increase:
google.maps.event.addDomListener(zoomIncrease, 'click', function() {
zoom = MainMap.getZoom();
MainMap.setZoom(zoom+1);
// Other Code parts
});
// Setup the click event listener for Zoom decrease:
google.maps.event.addDomListener(zoomDecrease, 'click', function() {
zoom = MainMap.getZoom();
MainMap.setZoom(zoom-1);
});
}
あなたの初期化関数:
function initializeMap() {
var latlng = new google.maps.LatLng(38.6, -98);
var options = {
zoom : 5,
center : latlng,
mapTypeId : google.maps.MapTypeId.ROADMAP,
// Other Options
};
MainMap = new google.maps.Map(document.getElementById("google-map-canvas"),
options);
// The main part - Create your own Custom Zoom Buttons
// Create the DIV to hold the control and call the zoomControl()
var zoomControlDiv = document.createElement('div'),
zoomLevelControl = new zoomControl(MainMap, zoomControlDiv);
zoomControlDiv.index = 1;
MainMap.controls[google.maps.ControlPosition.RIGHT_TOP].push(zoomControlDiv);
}
それが役に立てば幸い