远程引导模式与谷歌地图
Remote Bootstrap Modal with Google Maps
我有麻烦加载一个Ajax模式与谷歌地图在它。它所显示的只是模态中的灰色轮廓。我知道谷歌地图API在那里,因为它在模态之外工作。如有任何帮助,我将不胜感激。
Index Page Javascript
$('.update').click(function(e) {
$('body').modalmanager('loading');
$("#ajax-modal-1").load('detail.php', '', function(){
$("#ajax-modal-1").modal().addClass('modal-big');
});
});
模态HTML
...
<div class="row">
<div class="col-sm-12">
<div class="gmap" id="gmap"></div>
</div>
</div>
...
模态Javascript
...
$('body').on('show.bs.modal', '#ajax-modal-1', function () {
google.maps.event.addDomListener(window, 'load', initialize);
});
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(-34.397, 150.644),
zoom: 8
};
var map = new google.maps.Map(document.getElementById("gmap"),
mapOptions);
}
...
在Modal Javascript中尝试以下操作:
var map;
var location = new google.maps.LatLng(-34.397, 150.644);
var marker = new google.maps.Marker({ position : location });
function initialize() {
var mapOptions = { ... };
map = new google.maps.Map(document.getElementById("gmap"), mapOptions);
marker.setMap(map);
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
};
google.maps.event.addDomListener(window, 'load', initialize);
google.maps.event.addDomListener(window, "resize", resizingMap());
$('#ajax-modal-1').on('show.bs.modal', function() {
resizeMap();
})
function resizeMap() {
if(typeof map =="undefined") return;
setTimeout( function(){resizingMap();} , 400);
}
function resizingMap() {
if(typeof map =="undefined") return;
var center = map.getCenter();
google.maps.event.trigger(map, "resize");
map.setCenter(center);
}
HTML: <a href="#ajax-modal-1" class="btn" data-toggle="modal">Launch Modal</a>
<div class="modal fade" id="ajax-modal-1">
...
<div id="gmap"></div>
...
</div>
相关文章:
- 在bootstrap3模式中以谷歌地图为中心发布..不断变化
- 谷歌地图-模式窗口(Wordpress ACF)
- 谷歌地图API v3.19在Internet Explorer Quirks模式下损坏
- 引导模式下的谷歌地图灰色屏幕
- 谷歌地图API:具有多种传输模式的路线
- 在绘图中更改“绘图模式”谷歌地图v3的管理器
- 如何强制谷歌地图进入精简模式(没有WebGL)
- 谷歌地图简单的模式叠加
- 谷歌地图重新打开了模式问题
- 谷歌地图API严格遵守模式
- 谷歌地图不会出现在模式弹出菜单中
- 不能在bootstrap模式上显示谷歌地图
- 谷歌地图不填充模式弹出
- (React)打开一个模式上的谷歌地图标记点击
- 远程引导模式与谷歌地图
- 为什么在调试模式外添加谷歌地图会导致d3.js刷重绘崩溃?
- 谷歌地图在Bootstrap模式.平移/缩放鼠标手势不工作
- 谷歌地图多地图引导模式不起作用
- 点击谷歌地图标记,显示一个模式
- 显示一个谷歌地图上的引导模式