我正在使用 Gmaps4rails,我设法让它在标签内工作,将这段代码添加到标签功能中。
$(function() {
$( "#tabs" ).tabs({
fx: { opacity: 'toggle' },
select: function(event, ui) {
jQuery(this).css('height', jQuery(this).height());
jQuery(this).css('overflow', 'hidden');
},
show: function(event, ui) {
jQuery(this).css('height', 'auto');
jQuery(this).css('overflow', 'visible');
google.maps.event.trigger(map, 'resize');
}
});
http://hik-fyp.heroku.com/en/events/31
正如您在此示例中看到的(向下滚动并单击“ map ”选项卡), map 看起来不错,但标记就在左上角。标记在正确的位置, map 不在中心。
知道这是为什么吗?
最佳答案
如果它只是 map 的标记:
var lat = Gmaps.map.markers[0].lat;
var lng = Gmaps.map.markers[0].lng;
var centerpoint = new google.maps.LatLng(lat, lng);
Gmaps.map.map.setCenter(centerpoint);
最好在创建标记时提供此线
关于ruby-on-rails - 本地图在选项卡内时,gmaps4rails 会在 map 外显示标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14858400/