2012-11-09 152 views
5

我使用ExpressionEngine 2.5.3和谷歌地图ExpressionEngine 3.0.190(又名3.1测试版),用下面的代码:Overring在谷歌地图的地图缩放级别ExpressionEngine

{exp:gmap:init id="map1" class="gmap" scrollwheel="false" style="width:930px;height:500px" clusterStyles="{url: '/assets/images/cluster-icon-blue.png', textColor: '#fff', textSize: '12', height: 52, width: 53, anchor: [0, 0]}" overviewMapControl="true" overviewMapControlOptions="{opened:true}"} 

{exp:channel:entries channel="people" status="open" disable="categories|category_fields|member_data|pagination" limit="1000" dynamic="no" sort="asc"} 
    {cf_people_geo_location id="map1" show_one_window="true" icon="/assets/images/aabc-map-icon-white.png" infobox="true" offsetY="-45" offsetX="15" closeBoxMargin="5px" class="ui-infobox-dark" closeBoxURL="/themes/third_party/gmap/css/images/white-close-button.png" style="width: '250px'" clearanceX="10" show_one_window="true" clustering="true"} 
     <p><a href="/register/{url_title}/" title="View {title}">View {title} &raquo;</a></p> 
    {/cf_people_geo_location} 
{/exp:channel:entries} 

是否有可能设置地图在页面加载时使用的缩放级别?它似乎根据绘制的点自动设置,但我想重写此值并放大几个凹槽。

感谢,

科技教育

回答

1

使用extend_bounds参数,并将其设置为“假”

https://objectivehtml.com/google-maps/documentation/tag/marker#extend_bounds

试试这个:

{exp:gmap:init id="map1" class="gmap" scrollwheel="false" style="width:930px;height:500px" clusterStyles="{url: '/assets/images/cluster-icon-blue.png', textColor: '#fff', textSize: '12', height: 52, width: 53, anchor: [0, 0]}" overviewMapControl="true" overviewMapControlOptions="{opened:true}" zoom="10"} 

{exp:channel:entries channel="people" status="open" disable="categories|category_fields|member_data|pagination" limit="1000" dynamic="no" sort="asc"} 
    {cf_people_geo_location id="map1" show_one_window="true" icon="/assets/images/aabc-map-icon-white.png" infobox="true" offsetY="-45" offsetX="15" closeBoxMargin="5px" class="ui-infobox-dark" closeBoxURL="/themes/third_party/gmap/css/images/white-close-button.png" style="width: '250px'" clearanceX="10" show_one_window="true" clustering="true" extend_bounds="false"} 
     <p><a href="/register/{url_title}/" title="View {title}">View {title} &raquo;</a></p> 
    {/cf_people_geo_location} 
{/exp:channel:entries} 
+0

感谢贾斯汀。鉴于页面上有1个地图和500个标记,我甚至没有想到要在标记标记内添加扩展边界参数以使缩放参数有效。我刚刚尝试过您的代码组合,现在可以使用缩放参数。我注意到你也需要添加'中心'参数,否则,它将集中在世界的中心,而不是中心点。 – Stephen

1

没有为GMAP标签一个zoom=""参数,除了有时我发现它不工作(或我没有正确地使用它以某种方式)。

为了得到它放大到我想要的水平,我手动添加一些正规的谷歌地图(不是插件)代码更接近页面的末尾:

<script> 
    map1_map.setZoom(15); 
</script> 
+0

它没有工作因为... e您可能没有使用extend_bounds =“false”参数。你的JS是正确的(我也是这样做的),但是默认情况下,脚本根据所有标记的边界调整了事物的大小。这一切都是异步发生的,所以如果不阻止边界自动扩展(extend_bounds =“false”),那么它将无法正常工作,因为缩放方法在返回边界之前执行。 (有点令人困惑) –

+0

感谢您使用JS选项Jason的回复。听起来像你用我的缩放参数犯了同样的错误。 – Stephen

相关问题