谷歌地图没有;t在jquery mobile中加载
Google map didn't load in jquery mobile
我不知道为什么当我试图在我的应用程序上显示地图时,它不起作用。。只是灰色,但当我在Jsfidle上运行时,一切都很好。我认为这是关于pageshow的,如果我把它改为pageinit,映射就没有完全加载,我已经把所有的高度和宽度都改为100%,但仍然没有完全加载。。
<html lang="en">
<head>
<title>Maps</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?v=3&sensor=false&language=en"> </script>
<script type="text/javascript">
var map;
function initialize()
{
map = new google.maps.Map(document.getElementById('map_canvas'), {
zoom: 7,
center: new google.maps.LatLng(38.0457918, 23.7676337),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var currentPositionMarker = new google.maps.Marker({
position: new google.maps.LatLng(38.0457918, 23.7676337),
map: map,
title :"hei"
});
}
$(document).on("pageshow", "#basic-map", function() {
initialize();
});
</script>
</head>
<body>
<div id="basic-map" data-role="page">
<div data-role="header">
<h1><a data-ajax="false" href="/">examples</h1>
</div>
<div data-role="content">
<p>this is paragraph</p>
<ul data-role="listview" data-inset="true" data-divider-theme="b">
<li data-role="list-divider">Map</li>
<div id="map_canvas" style="height:320px;"></div>
</ul>
</div>
</div>
</body>
</html>
我确实尝试添加了这段代码,但地图已经完全加载,但标记没有居中。。
$( document ).bind( "pageshow", function( event, data ){
google.maps.event.trigger(map, 'resize');
});
第二件事是标题标记没有出现。请帮忙。。感谢
触发调整大小事件后重置地图的中心位置。
$( document ).bind( "pageshow", function( event, data ){
google.maps.event.trigger(map, 'resize');
map.setCenter(currentPositionMarker.getPosition());
});
(在使currentPositionMarker
像map
变量一样全局之后)
相关文章:
- 无法从jquery Mobile导航栏重定向到另一个页面
- jquery mobile上多个页面上的一个表单
- window.location使用jquery mobile实现chrome跳转
- 防止jQuery Mobile中的ajax缓存
- 如何在JQUERY Mobile上放置谷歌地图
- JQuery Mobile Javascript复杂方程式
- jQuery Mobile Undefined不是一个函数
- jQuery mobile not going through ID
- 如何使用javascript或jquery mobile从url读取和显示XML文件
- jQuery Mobile Collapse上的AJAX请求
- 应用程序在呈现Jquery Mobile之前显示无样式的Html
- 如何在jQuery Mobile 1.4 Datepicker中创建事件
- UIWebview赢得't通过基本身份验证加载动态加载的资源(通过jQuery mobile)
- jQuery Mobile到其他页面的锚链接不起作用
- 如何在jQuery Mobile中设置100%宽度的输入类型日期
- JQuery Mobile破坏了我的布局:如何禁用自动打字
- 防止用户在jQuery Mobile中ajax加载页面时单击其他位置
- 根据手机上是否存在文件,在jQuery mobile中动态填充列表视图
- Image Sprites和jQuery Mobile Ajax导航的问题
- jQuery Mobile:如何在$.Mobile.changePage之前运行回调函数