在引导选项卡上调整大小后,Google地图的标记不居中 [英] Google map's marker not center after resize on bootstrap tab
本文介绍了在引导选项卡上调整大小后,Google地图的标记不居中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我购买了地理位置地图脚本,并将其应用于引导选项卡时,它仅显示小左上角。
I bought a geolocation map script and when applied to bootstrap tab it will only shown small top left span. I added resize to overcome it.
$(document).ready(function() { $(‘a[href="#tab2"]’).click(function(e) { setTimeout(initialise, 1000); }); </script>
function initialise() {
var myMap = document.getElementById('map-myid1');
google.maps.event.trigger(myMap, 'resize');
};
});
我面对的问题是地图不是中心的标记,它会隐藏地图外的左侧。如何解决它?
The problem I am facing is the marker of map not center, it will hide left outside of map. How to fix it?
推荐答案
在引导程序3.xx 中,此脚本将有助于:
In bootstrap 3.x.x, this script will help:
var map;
google.maps.visualRefresh = true; // Enable the visual refresh
function initialize() {
// map initialization code
}
google.maps.event.addDomListener(window, 'load', initialize);
$(function () {
$('a[href="#Location"]').on('shown.bs.tab', function(e) {
lastCenter=map.getCenter();
google.maps.event.trigger(map, 'resize');
map.setCenter(lastCenter);
});
});
其中 a [href =#位置]
是选项卡的锚点选择器。
where a[href="#Location"]
is the anchor selector of the tab.
这篇关于在引导选项卡上调整大小后,Google地图的标记不居中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文