我已经实现了一个自定义ImageMapType,它根据getTileUrl()的给定坐标和缩放级别返回有效的切片网址。
new google.maps.ImageMapType({
name: 'Satellite',
getTileUrl: function(coord, zoom) {
var p_type = "satellite",
z = zoom - 11,
corr = Math.pow(2, zoom) - Math.pow(2, z),
p_x = coord.x - corr,
p_y = coord.y - corr,
maxCoord = Math.pow(2, (z+1)) - 1;
if (p_x > maxCoord || p_y > maxCoord || p_x < 0 || p_y < 0) {
return 'http://maps.gstatic.com/intl/en_us/mapfiles/transparent.png';
}
p_x = (p_x < 16 ? '0' : '') + p_x.toString(16);
p_y = (p_y < 16 ? '0' : '') + p_y.toString(16);
return 'http://map.example.com/' + p_type + '/' + (z + 1) + '/tile_' + p_y + p_x + '.jpg';
},
tileSize: new google.maps.Size(128, 128),
isPng: false,
minZoom: 11,
maxZoom: 16
});
我有128x128的图块用于缩放级别11到16.通过将ImageMapTypeOptions对象的maxZoom属性增加到16以上,可以缩放到有图块的位置(但当然不会出现任何图块,但是标记和折线确实有效)。在这种情况下,我希望从前一个缩放图层拉伸图块(与更改缩放级别时的过渡效果相同)。
有可能吗?如果是这样,怎么样?
答案 0 :(得分:1)
非常好的问题。这在理论上应该可以在客户端上进行,但作为getTileUrl
方法
google.maps.ImageMapType
对象必须返回URL,您必须在使用此对象时在服务器上执行此操作。
另一种可能性是使用更通用的google.maps.MapType
对象,并定义自己的getTile
方法。然后你可以返回你自己的拉伸<img>
元素。