2012-11-09 148 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

相關問題