使用jquery gmap3& amp; amp; ...设置最大缩放级别自动调整 [英] Setting a max zoom level using jquery gmap3 & autoFit

查看:122
本文介绍了使用jquery gmap3& amp; amp; ...设置最大缩放级别自动调整的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在gmap3插件上使用'autoFit',以便缩放到地图上对象的最佳级别。问题是,只有1个对象放大到最大水平,这太过分了。我怎样才能让它不比缩放级别14更进一步?

I am using 'autoFit' on the gmap3 plugin so it zooms to the best level for the objects on the map. The problem is when there is only 1 object it zooms in to the maximum level which is too far. How can i make it go no futher than zoom level 14?

谢谢。

Thanks.

推荐答案

您可以使用maxZoom,但它会设置地图的最大缩放比例,而不是自动调整功能。这意味着如果用户想要的话,用户将无法进一步放大地图。

You can use maxZoom, but that sets the max zoom of the map and not of the autofit function. That means that the user will not be able to zoom further in on the map if they would want to.

map:{
      center: true,
      zoom: 10,
      maxZoom: 18
    }

相反,我为每个点添加了一个隐藏的圆或半径,其大小将使地图缩小到我希望的缩放级别。这样用户仍然可以进一步放大,如果他们想要。

Instead I added a hidden circle or radius to every point with a size that would make the map zoom out to the zoom level I would want it to be. This way the user can still zoom further in if they would want to.

$('#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'
);

这篇关于使用jquery gmap3& amp; amp; ...设置最大缩放级别自动调整的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆