我在gmap3插件上使用'autoFit',因此它放大到地图上对象的最佳级别。问题是,只有1个对象放大到最大水平,这太过分了。我怎样才能让它比缩放级别14更进一步?使用jquery设置最大缩放级别gmap3&autoFit
谢谢。
我在gmap3插件上使用'autoFit',因此它放大到地图上对象的最佳级别。问题是,只有1个对象放大到最大水平,这太过分了。我怎样才能让它比缩放级别14更进一步?使用jquery设置最大缩放级别gmap3&autoFit
谢谢。
您可以使用MAXZOOM,但设置地图,而不是自动调整功能的最大变焦。这意味着如果用户愿意,用户将无法在地图上进一步放大。
map:{
center: true,
zoom: 10,
maxZoom: 18
}
相反,我为每个点添加了一个隐藏的圆或半径,其大小会使地图缩小到我希望的缩放级别。这样用户仍然可以进一步放大,如果他们想。
$('#test').gmap3(
{
action: 'addMarker',
latLng: "your data input for markers",
map:{
center: true,
zoom: 10
}
},
{
action: 'addCircle',
latLng: "your data input for markers",
options: {
radius : 75,
strokeOpacity: 0,
fillOpacity: 0,
}
},
'autofit'
);
+1总是想着用户 –
您可以将MAXZOOM属性添加到gmap3插件的地图属性:
$('#test1').gmap3(
{
action: 'addInfoWindow',
address: "some place name",
map:{
center: true,
zoom: 5,
maxZoom: 10
},...
这似乎适用于我在gmap3版本5.1.1。只需使用自动调整:{maxZoom:14}。这告诉地图只能在自动调整时放大到14级,并允许用户使用鼠标或变焦控制进行放大或缩小。
$(function(){
$("#test").gmap3();
$('#test-ok').click(function(){
var addr = $('#test-address').val();
if (!addr || !addr.length) return;
$("#test").gmap3({
getlatlng:{
address: addr,
callback: function(results){
if (!results) return;
$(this).gmap3({
marker:{
latLng:results[0].geometry.location,
map:{
center: true,
},
},
autofit:{maxZoom: 14},
});
}
}
});
});
$('#test-address').keypress(function(e){
if (e.keyCode == 13){
$('#test-ok').click();
}
});
});
非常感谢你的回答! [gmap3 documentation for autofit](http://gmap3.net/en/catalog/16-misc/autofit-58): – khustochka
非常欢迎!是的,我同意gmap3的文档非常含糊,它通常要求用户比大多数插件做更多的试验和错误。 – ryan
http://code.google.com/apis/maps/documentation/javascript/reference.html#MapOptions – Val
大概就像'map.maxZoom = 14'或'map.maxZoom(14)' – Val
我正在使用gmap3 jQuery插件而不是股票API。 – 472084