- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在我的 Phonegap 应用程序中使用 Google Maps API v3。目前我可以让 map 在我的本地主机上显示得很好,但是当我将其上传到 Phonegap 构建并尝试在 android 模拟器上查看它时,jquery 移动框架无法加载页面。
我很茫然,我已经查看了这里所有的 GMap 问题,但没有找到任何帮助。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=screen.width, initial-scale=1.0, user-scalable=no" />
<title>DD Buddy App</title>
<link rel="stylesheet" href="themes/ddBuddy.min.css" />
<link rel="stylesheet" href="themes/jquery.mobile.icons.min.css" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.0/jquery.mobile.structure-1.4.0.min.css" />
<link rel="stylesheet" href="css/style.css" type="text/css" />
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).on('mobileinit', function () {
$.mobile.defaultPageTransition = 'slide';
});
</script>
<script src="http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.js"></script>
<script src="js/parse-1.2.16.min.js"></script>
<!-- cordova -->
<script src="phonegap.js"></script>
</head>
<body class="site">
<!-- Home/Landing Page -->
<div data-role="page" data-theme="a" id="map">
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="maps/jquery.ui.map.js"></script>
<script type="text/javascript" src="maps/jquery.ui.map.services.js"></script>
<div data-role="header" data-position="inline" class="header">
<img src="img/logo.png" title="logo" class="logo" />
<img src="img/home.png" title="home" class="homeImg" />
<img src="img/menu.png" title="menu" class="menuImg" />
</div>
<div class="ui-content ui-page-theme-a" data-form="ui-page-theme-a" data-theme="a" role="main">
<div id="map_canvas" style="width:100%;height:500px;background-color:#CCC;"></div>
</div>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript" src="ui/jquery.ui.map.js"></script>
<script type="text/javascript">
$(function(){
$("#map_canvas").gmap();
$(".menuImg").on("touchend", function(){
$.mobile.changePage("menu.html", {
transition: 'slide'
});
});
$(".homeImg").on("touchend", function(){
$.mobile.changePage("home.html", {
transition: 'slide'
});
});
});
</script>
</div>
</body>
</html>
最佳答案
在继续之前(我将研究代码),我建议的第一件事是将所有脚本调用替换为本地脚本。我的意思是下载一个 jquery mobile 副本并将其存储在您的 Assets 文件夹中,而不是每次都从服务器调用它。所有的 CSS 和任何可以存储在本地的东西都是一样的。不要忘记您是在移动设备上进行部署,人们很可能会对他们的移动数据设置数据上限,因此您希望让您的应用程序尽可能精简数据。我会尽快更新答案,一旦我把一个版本放到我的手机上看看有什么问题。
埃米尔
你的代码很乱,看起来像是复制粘贴,甚至没有检查什么。我清理了一下它应该更接近于此:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=screen.width, initial-scale=1.0, user-scalable=no" />
<title>DD Buddy App</title>
<link rel="stylesheet" href="themes/ddBuddy.min.css" />
<link rel="stylesheet" href="themes/jquery.mobile.icons.min.css" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.0/jquery.mobile.structure-1.4.0.min.css" />
<link rel="stylesheet" href="css/style.css" type="text/css" />
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="ui/jquery.ui.map.js"></script>
<script src="js/parse-1.2.16.min.js"></script>
<script src="phonegap.js"></script>
<!-- cordova -->
</head>
<body class="site">
<!-- Home/Landing Page -->
<div data-role="page" data-theme="a" id="map">
<div data-role="header" data-position="inline" class="header">
<img src="img/logo.png" title="logo" class="logo" />
<img src="img/home.png" title="home" class="homeImg" />
<img src="img/menu.png" title="menu" class="menuImg" />
</div>
<div class="ui-content ui-page-theme-a" data-form="ui-page-theme-a" data-theme="a" role="main">
<div id="map_canvas" style="width:100%;height:500px;background-color:#CCC;"></div>
</div>
<script type="text/javascript">
$(document).on('mobileinit', function () {
$.mobile.defaultPageTransition = 'slide';
});
$(function(){
$("#map_canvas").gmap();
$(".menuImg").on("touchend", function(){
$.mobile.changePage("menu.html", {
transition: 'slide'
});
});
$(".homeImg").on("touchend", function(){
$.mobile.changePage("home.html", {
transition: 'slide'
});
});
});
</script>
</div>
</body>
</html>
注意事项: - 确保您的 asset/www 文件夹中有一个 UI 文件夹,其中包含 jquery.ui.map.js - 如前所述,下载副本并将每个 JS 和 CSS 的副本存储在本地,避免每次都调用互联网来获取它们 - 确保删除不必要的库(你在哪里使用解析 js?)
话虽这么说,如果您执行所有这些操作并使用上面的代码,您的手机上就会显示 map ,我不知道模拟器,因为我从不使用模拟器,我使用真实设备进行测试。
关于javascript - 谷歌地图与 Phonegap 的集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21864017/
Example image 如何在 Phonegap 中添加像这张图片这样的 float 气泡通知。 最佳答案 没有您正在寻找的“开箱即用”插件。但是,您可以创建自己的插件或简单地使用 phonega
我正在使用 HTML 和 JS、JQuery Mobile 构建一个应用程序,并使用 PhoneGap Build 进行打包。客户想知道是否可以添加打印功能...有人知道吗?没有 PG Build 打
我已经安装了 Phonegap 使用 $ npm install -g PhoneGap 我也创建了项目。之后我做了 $ PhoneGap build android 它给出了 [phonegap]
我尝试创建 Phonegap 项目,其中需要集成 ASIHTTPRequest 和 JASON 引用, 并出现以下错误 ld: duplicate symbol _SBJSONErrorDomain
我有一个 Phonegap 应用程序,我从早期版本的 Phonegap 开始,我想升级到最新版本。我需要采取哪些步骤来升级它? 我正在寻求一般性答案,但我的具体情况是 Phonegap 1.1.0 -
我已在我的 MAC 电脑(IOS 10.5.8,SDK 3.1.2)上成功安装 PhoneGap。尝试创建一个新的基于 PhoneGap 的应用程序,包含 PhoneGap 框架并将所需的文件复制到
我正在 phonegap 中为三个不同的平台构建一个应用程序:Android、iOS 和 Blackberry。这样做时,我必须检测设备类型,以便我可以在不同平台和不同设备(如 Android Pho
开始在Mac上使用phonegap(Xcode 4,构建iPhone应用程序)我已经阅读了很多有关名为phonegap.plist的文件的内容,包括外部URL的白名单和其他内容。 这是我的问题,我在
所以我有一个运行 Phonegap 1.4.0 的应用程序(不要问),我决定升级到 1.8.1,这样做时 Phonegap 全局变量不再存在,将被替换为实用程序。 所以我转换了每一次出现: var t
我尝试了什么: 我正在开发一个安卓应用程序。在我的应用程序中,我必须打开 -> 向用户显示 Microsoft Office 文档(doc、docx、xls、xlsx、ppt、pptx)内容。为此,我
使用phonegap制作iOS应用时,ChildBrowser插件可以打开一个可以使用phonegap功能的远程页面吗? 例如:在phonegap应用程序中的index.html,调用childbro
我有一个带有 angularjs 的网络应用程序。我想使用 phonegap 将它变成一个移动应用程序 (android)。 我使用了 phonegap 构建:https://build.phoneg
我正在使用 Phonegap build 为每个平台生成可执行文件。每次更改代码时,我都必须在 phonegap build 上上传代码并生成新的 Apk 文件(适用于 android)。我不想在真实
我很生气,这是毫无疑问的,除了明显的可见差异之外,有人报告高度为: $('body').outerHeight(); //1780 与在我的本地 Windows 8 机器上使用 phonegap
我最近使用 phonegap 完成了我的第一个混合应用程序项目。当谈到公开测试时,我有点害怕签名过程。我从这里以及网上的其他地方阅读了许多不同的建议 fragment 来完成这项工作。 以下是如何为
我是 phonegap 的新手,我尝试创建一个简单的 phonegap 应用程序。 使用命令行安装phonegap后:--- 我已经成功创建了项目,但是当我尝试运行 phonegap build io
我正在为 Android 平台制作一个 phonegap 应用程序。在这个应用程序中,我想在多个 html 页面中滑动导航。请告诉我该怎么做。要么在单个 html 页面中完成,要么我必须为此滑动导航创
是否有任何插件可用于 Juce我可以添加哪些库可以同时适用于 IOS 和 android?如果没有,我如何集成 Juce我的电话间隙应用程序中的库? 最佳答案 没有插件。但您可以使用介绍榨汁机来创建不
Phonegap 刚刚推出了一种方法,可以使用以下命令使用本地服务器立即查看您对 phonegap 应用程序的更改: phonegap serve 然后通过下载 PhoneGap Developer
我们对如何集成phonegap插件,然后使用phonegap build构建我们的移动应用程序有一些疑问,这可能吗? 当您使用 Phonegapbuild 构建您的应用程序时,它会为所有受支持的设备构
我是一名优秀的程序员,十分优秀!