Javascript Jquery手机弹出窗口上方/与谷歌地图
使用jQuery Mobile,我无法在加载google地图的情况下获得弹出窗口。 如果我触摸id=“popubasic”,则不会弹出任何内容。非常奇怪,但是如果没有加载GoogleMapAPI,弹出窗口就会工作 >Javascript Jquery手机弹出窗口上方/与谷歌地图,javascript,jquery,jquery-mobile,google-maps-api-3,jquery-mobile-popup,Javascript,Jquery,Jquery Mobile,Google Maps Api 3,Jquery Mobile Popup,使用jQuery Mobile,我无法在加载google地图的情况下获得弹出窗口。 如果我触摸id=“popubasic”,则不会弹出任何内容。非常奇怪,但是如果没有加载GoogleMapAPI,弹出窗口就会工作 > 给我啤酒 $.mobile.page.prototype.options.domCache=true; $.mobile.allowCrossDomainPages=true; $(文档)。on('pageshow','#map',函数(事件) { 最大高度(); $(文档)。
给我啤酒
$.mobile.page.prototype.options.domCache=true;
$.mobile.allowCrossDomainPages=true;
$(文档)。on('pageshow','#map',函数(事件)
{
最大高度();
$(文档)。在('click','#myposition',函数(事件){
getCurrentPosition(onSuccess,onError,{'EnableHighAccurance':true,'timeout':20000});
});
});
地图标题
这是一个完全基本的弹出窗口,没有设置选项。
有人也有同样的问题吗?我想不出来
格里茨
弗兰克工作示例:
我更改了您的示例,如果您单击按钮#myposition,将显示弹出窗口
HTML:
<!DOCTYPE html>
<html>
<head>
<title>jQM Complex Demo</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=no; target-densityDpi=device-dpi"/>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
<script>
$(document).bind("mobileinit", function(){
$.mobile.page.prototype.options.domCache = true ;
$.mobile.allowCrossDomainPages = true;
});
</script>
<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
</head>
<body>
<div data-role="page" id="map">
<div data-role="header" data-theme="b">
<a href="index.html" data-icon="grid" rel="external">Menu</a>
<h1>Map Header</h1>
</div>
<div data-role="content" style="width:100%; height:100%; padding:0;">
<div data-role="popup" id="popupBasic">
<p> This is popup</p>
</div>
<div id="map_canvas" style="width:100%;height:100%"></div>
</div>
<div data-role="footer" data-theme="b" data-position="fixed">
<div data-role="navbar">
<ul>
<li>
<a href="#leftpanel" data-role="button" data-inline="true" data-icon="grid" >Date</a>
</li>
<li>
<a href="#" data-icon="star" id="testbtn">Favs</a>
</li>
<li>
<a href="#" data-icon="gear" id="myposition">My position</a>
</li>
<li>
<a href="#popupBasic" data-rel="popup" id="openPopup">Open Popup</a>
</li>
</ul>
</div>
<!-- /navbar -->
</div>
</div>
</body>
</html>
Javascript:
#popupBasic {
width: 300px !important;
height: 300px !important;
}
$(document).on('pageshow', '#map', function (event) {
max_height();
$(document).on('click', '#myposition', function (event){
navigator.geolocation.getCurrentPosition(onSuccess, onError,{'enableHighAccuracy':true,'timeout':20000});
});
});
function max_height() {
var header = $.mobile.activePage.find("div[data-role='header']:visible");
var footer = $.mobile.activePage.find("div[data-role='footer']:visible");
var content = $.mobile.activePage.find("div[data-role='content']:visible:visible");
var viewport_height = $(window).height();
var content_height = viewport_height - header.outerHeight() - footer.outerHeight();
if((content.outerHeight() - header.outerHeight() - footer.outerHeight()) <= viewport_height) {
content_height -= (content.outerHeight() - content.height());
}
$.mobile.activePage.find('[data-role="content"]').height(content_height);
}
function onSuccess(position) {
var minZoomLevel = 15;
var map = new google.maps.Map(document.getElementById('map_canvas'), {
zoom: minZoomLevel,
center: new google.maps.LatLng(position.coords.latitude, position.coords.longitude),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
}
function onError() {
alert('Error');
}
$(文档).on('pageshow','#map',函数(事件){
最大高度();
$(文档)。在('click','#myposition',函数(事件){
getCurrentPosition(onSuccess,onError,{'EnableHighAccurance':true,'timeout':20000});
});
});
函数最大高度(){
var header=$.mobile.activePage.find(“div[data role='header']:可见”);
var footer=$.mobile.activePage.find(“div[data role='footer']:visible”);
var content=$.mobile.activePage.find(“div[data role='content']:visible:visible”);
var viewport_height=$(窗口).height();
var content_height=viewport_height-header.outerHeight()-footer.outerHeight();
if((content.outerHeight()-header.outerHeight()-footer.outerHeight())工作示例:
我更改了您的示例,如果您单击按钮#myposition,将显示弹出窗口
HTML:
<!DOCTYPE html>
<html>
<head>
<title>jQM Complex Demo</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=no; target-densityDpi=device-dpi"/>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
<script>
$(document).bind("mobileinit", function(){
$.mobile.page.prototype.options.domCache = true ;
$.mobile.allowCrossDomainPages = true;
});
</script>
<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
</head>
<body>
<div data-role="page" id="map">
<div data-role="header" data-theme="b">
<a href="index.html" data-icon="grid" rel="external">Menu</a>
<h1>Map Header</h1>
</div>
<div data-role="content" style="width:100%; height:100%; padding:0;">
<div data-role="popup" id="popupBasic">
<p> This is popup</p>
</div>
<div id="map_canvas" style="width:100%;height:100%"></div>
</div>
<div data-role="footer" data-theme="b" data-position="fixed">
<div data-role="navbar">
<ul>
<li>
<a href="#leftpanel" data-role="button" data-inline="true" data-icon="grid" >Date</a>
</li>
<li>
<a href="#" data-icon="star" id="testbtn">Favs</a>
</li>
<li>
<a href="#" data-icon="gear" id="myposition">My position</a>
</li>
<li>
<a href="#popupBasic" data-rel="popup" id="openPopup">Open Popup</a>
</li>
</ul>
</div>
<!-- /navbar -->
</div>
</div>
</body>
</html>
Javascript:
#popupBasic {
width: 300px !important;
height: 300px !important;
}
$(document).on('pageshow', '#map', function (event) {
max_height();
$(document).on('click', '#myposition', function (event){
navigator.geolocation.getCurrentPosition(onSuccess, onError,{'enableHighAccuracy':true,'timeout':20000});
});
});
function max_height() {
var header = $.mobile.activePage.find("div[data-role='header']:visible");
var footer = $.mobile.activePage.find("div[data-role='footer']:visible");
var content = $.mobile.activePage.find("div[data-role='content']:visible:visible");
var viewport_height = $(window).height();
var content_height = viewport_height - header.outerHeight() - footer.outerHeight();
if((content.outerHeight() - header.outerHeight() - footer.outerHeight()) <= viewport_height) {
content_height -= (content.outerHeight() - content.height());
}
$.mobile.activePage.find('[data-role="content"]').height(content_height);
}
function onSuccess(position) {
var minZoomLevel = 15;
var map = new google.maps.Map(document.getElementById('map_canvas'), {
zoom: minZoomLevel,
center: new google.maps.LatLng(position.coords.latitude, position.coords.longitude),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
}
function onError() {
alert('Error');
}
$(文档).on('pageshow','#map',函数(事件){
最大高度();
$(文档)。在('click','#myposition',函数(事件){
getCurrentPosition(onSuccess,onError,{'EnableHighAccurance':true,'timeout':20000});
});
});
函数最大高度(){
var header=$.mobile.activePage.find(“div[data role='header']:可见”);
var footer=$.mobile.activePage.find(“div[data role='footer']:visible”);
var content=$.mobile.activePage.find(“div[data role='content']:visible:visible”);
var viewport_height=$(窗口).height();
var content_height=viewport_height-header.outerHeight()-footer.outerHeight();
if((content.outerHeight()-header.outerHeight()-footer.outerHeight())其他函数在哪里?onSuccess和OneError?z-index可能有问题?z-index没有任何帮助。其他函数在哪里?onSuccess和OneError?z-index可能有问题?z-index没有任何帮助。我想让事情复杂化:D现在看看我的JSFIDLE示例。我知道你需要一个弹出窗口我已经试过了:)但在我的设备上弹出窗口不会显示,我在Logcarandroid或iOS中没有看到任何奇怪的错误?我有足够的时间来测试:)哈哈,我是安卓版的Heheddle你在安卓和phonegap上用谷歌api测试过Gajotres吗?我想让事情复杂化:现在看看我的JSFIDLE示例。我知道你需要一个带有地图的弹出窗口。Gajotres我已经试过了:)但在我的设备上弹出窗口不会显示,我在Logcarandroid或iOS中没有看到任何奇怪的错误?我还有更多然后有足够的时间来测试这个:)哈哈,安卓对我来说,heheDid,你用安卓和phonegap上的谷歌api来测试Gajotres吗?