我相信您需要在函数中添加更多参数。
opacity: 1
repeatHorizontally: false,
repeatVertically: false
在您的方案中重复经常是可选的。这里是您的完整代码:
var map = new google.maps.Map(document.getElementById('map'), mapOptions);
var customMapType = new google.maps.ImageMapType({
getTileUrl: function(coord, zoom) {
if (zoom < 0 || zoom > maxZoom) return "";
var cols = baseCols * Math.pow(2, zoom);
var rows = baseRows * Math.pow(2, zoom);
if (coord.x < 0 || coord.x >= cols || coord.y < 0 || coord.y >= rows) {
return null;
}
return 'tiles/' + zoom + '/' + coord.y + "_" + coord.x + ".png";
},
tileSize: new google.maps.Size(256, 256),
minZoom: 0,
maxZoom: maxZoom,
name: 'custom',
opacity: 1,
repeatHorizontally: false,
repeatVertically: false
});
map.mapTypes.set('custom', customMapType);
map.setMapTypeId('custom');