- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在为我的组织开发一个应用程序,需要在 map 上显示其办公室位置,当用户单击链接时,应用程序将在浏览器上打开谷歌地图并显示用户当前位置和所选办公室标记之间的路线。这在 Android 应用程序中运行良好,但不适用于 iPhone/iPad 应用程序。我正在使用下面的代码:
我已经在index.html文件中声明了google api脚本
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
下面是location.html文件的代码
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
</head>
<body style="display: none; background-color: silver; color: green; font-size: small;">
<div data-role="main" class="ui-content">
<div data-role="content" id="contentMap">
<div id="map_canvas" style="position: absolute !important; top: 10px !important; right: 0; bottom: 5px !important; left: 0 !important;"></div>
</div>
</div>
<script src="js/location.js"></script>
</body>
</html>
下面是location.js文件的代码:
/* JavaScript content from js/location.js in folder common */
function OfficeLocation(latitude,longitude,name,address){
this.latitude = latitude;
this.longitude = longitude;
this.name = name;
this.address = address;
}
var officeLocationArray = [
new OfficeLocation(32.3947198, -90.1457959, "office location 1", "office location 1"),
new OfficeLocation(31.7138728, -89.1492813, "office location 1", "office location 1"),
new OfficeLocation(32.2777552, -90.1223944, 'office location 1', 'office location 1')
];
// would be used as users current location
var usersLat;
var usersLng;
var youAreHereMarkers; //markers to represent current user location ( blue marker is used). can replace with any image or gifs ( like blue dot gifs)
var map; //
var mapURL; //users location and destination selected by user are stored in this variablse in order to use it to open google map in new browser with route visible
var currentPosition; // will store lat/lng location for google map api.
var infowindow; //displays information about the location when user clicks marker on map
/**
* everthing happens here
*
* on success : getuser location,get new map , add user markers, add win job markers , add marker listeners that lets you open original google map with direction
* on failure: get new map, add all winjob marker
*/
$("#divLocation").on("pageshow", function(event, ui) {
alert("map initiliaziation started");
getUsersCurrentLocationAndPopulateMap();
});
/**
*
*/
function getUsersCurrentLocationAndPopulateMap() {
var options = {
enableHighAccuracy: true,
timeout: 10000,
maximumAge: 0
};
navigator.geolocation.getCurrentPosition(locationFound, locationNotFound, options);
}
/**
* creates new map, and adds all marker related information
* @param pos
*/
function locationFound(pos){
try{
var coords = pos.coords;
usersLat = coords.latitude;//pos.coords.latitude;
usersLng = coords.longitude;//pos.coords.longitude;
getNewMap();
addUsersLocationMarker();
addAllMarkers();
}catch (e) {
alert(e.message);
}
}
/**
* user location is not determined.
* possible gps sensor problem
* @param err
*/
function locationNotFound(err){
showAlert("Unable to determine your location.");
getNewMap();
addAllMarkers();
alert('ERROR(' + err.code + '): ' + err.message);
}
/**
* new map is created
*/
function getNewMap() {
try{
var zoomlevel = 7;
var usersLocation = new google.maps.LatLng(usersLat, usersLng);
map = new google.maps.Map(document.getElementById('map_canvas'), {
zoom : zoomlevel,
center : usersLocation,
mapTypeId : google.maps.MapTypeId.ROADMAP
});
}catch(e){
alert(e.message);
}
}
/**
* place users locatin markers on map and also all win job locations markers
* based on array provided
*/
function addUsersLocationMarker(){
try{
var blueMarker = new google.maps.MarkerImage(
'http://maps.google.com/mapfiles/ms/icons/blue-dot.png',
new google.maps.Size(37, 34), new google.maps.Point(0, 0),
new google.maps.Point(0, 19));
//placing users location map
//http://maps.google.com/mapfiles/ms/icons/blue-dot.png
youAreHereMarkers = new google.maps.Marker({
position : new google.maps.LatLng(usersLat, usersLng),
map : map,
animation : google.maps.Animation.BOUNCE,
title : "You are Here",
icon : blueMarker//'images/here.png'
});
}catch (e) {
alert(e.message);
}
}
/**
* reads all the marker informatin from officeLocationArray and place it on the map as clickable markers
*/
function addAllMarkers() {
//clickable region
var shape = {
coord : [ 1, 1, 1, 20, 18, 20, 18, 1 ],
type : 'poly'
};
// populalte markers on all WIN Job Center location
var numberOfLocations = officeLocationArray.length;
for (var i = 0; i < numberOfLocations; i++) {
var ofcLocation = officeLocationArray[i];
var flag = new google.maps.MarkerImage(
'http://googlemaps.googlermania.com/google_maps_api_v3/en/Google_Maps_Marker.png',
new google.maps.Size(37, 34), new google.maps.Point(0, 0),
new google.maps.Point(0, 19));
var myLatLng = new google.maps.LatLng(parseFloat(ofcLocation.latitude), parseFloat(ofcLocation.longitude));
var marker = new google.maps.Marker({
position : myLatLng,
map : map,
icon : flag,
shape : shape,
title : ofcLocation.name + "\n" + ofcLocation.address
});
// listens if user clicks on marker to display infowindow, and eventually driving to google map in new browser
google.maps.event.addListener(marker,'click',function() {
try{
if(infowindow){
infowindow.close();
}
map.setZoom(8);
map.setCenter(marker.position);
var destinationAddress = this.getTitle().split("\n");
mapURL = "http://www.google.com/maps/dir/'"+ usersLat + "," + usersLng + "'/'"+ destinationAddress[0]+","+ destinationAddress[1] + "'";
var contentString=destinationAddress[0]+ /*"<br />"+ destinationAddress[1]+*/ "<br/><div><a href='#' onClick='openGoogMap()' > Go to this location </a></div>";
infowindow = new google.maps.InfoWindow({
maxWidth: 200,
content : "<div style='overflow:hidden;line-height:1.35;min-width:200px;'>"+contentString+"</div>"
});
infowindow.open(map, this);
// showAlert(openMapString);
}catch (e) {
alert(e.message);
}
});
}
}
/**
* opens google map in a browser with information appended in mapURL
*/
function openGoogMap() {
WL.App.openURL(mapURL);
}
感谢任何帮助。
更新
工作灯版本:6.2.0.0
Xcode 版本:6
最佳答案
好的。得到答案了。由于我是在 XCode 6 中构建应用程序并使用 worklight 版本 6.2.0.0,这就是这段代码产生问题的原因。您可以从 IBM Website 阅读有关该问题的信息。 。要解决此问题,请下载以下内容 fix pack这会将您的工作灯版本更新到 6.2.0.1。完成此操作后,您必须在 pathToYourProject\YourProject\apps\yourAppName\iphone\native\yourAppName-Info.plist 文件中添加以下条目:
<key>NSLocationAlwaysUsageDescription</key>
<string>Permissions Message for App even when not in use</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Permissions Message for App when in use</string>
构建并重新部署您的应用程序,它现在应该可以正常工作。
关于javascript - Google map 无法在 iPhone/iPad worklight 6.2 应用程序上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26964543/
我妻子有一台 iPad,我想知道我是否可以用它来开发 iPad 应用程序?我假设答案是否定的。 最佳答案 Apple 的开发指南禁止商店中的此类应用程序,因此不幸的是,您不能使用 iPad 来制作 i
我开发了一个 iPad 应用程序,并为应用程序商店制作了分发配置文件,我需要在 30 台 iPad 上安装我开发的应用程序以进行一次事件,但我无法安装。我收到错误消息:(应用程序“xxxx”未安装在
我正在佛罗里达州开发一款 iPad/iPhone 应用程序,希望纽约的同事能帮我测试一下。纽约的测试人员没有 iMac,因为他们不在该地点进行任何开发。我只是想让他们验证他们所在位置的操作。有什么方法
我可以检测用户(音乐家)手指施加的力或压力吗? 最佳答案 还没有。 有一个技术演示展示了如何做到这一点。见 http://tenonedesign.com/blog/pressure-sensitiv
浏览器分辨率是多少?我已经在谷歌上搜索了一段时间,但不知何故我找不到它! 最佳答案 960x768 或 704x1024 关于ipad - iPad 的屏幕尺寸减去浏览器中的地址栏是多少?,我们在St
我的应用只能在横向使用,并且只能在横向启动。因此,iPad为横向时,左上角为(0,0),因此一切正常。 但是,当我拿起“ touchesBegan” ...时,它无法正常工作。只有当我像正确的三分之二
我在 ionic 中创建输入,它只接受数字。这适用于除 safari 和 ipad 之外的所有浏览器和设备。我不希望用户输入数字以外的任何内容。我尝试对输入事件进行正则表达式验证,但这并不能阻止用户输
是否可以在 iPad 中显示仅包含 0-9 数字的键盘?,我不希望键盘显示任何其他内容。我知道有这个 键盘类型:数字键盘 我们可以在 .xib 文件中,但它显示所有其他额外的字符,包括数字。我想使用这
我正在做一个SproutCore项目。我试图按原样在IPAD上获取该站点,但是CSS背景图像,onClick和重定向在IPAD上不起作用。 让我知道对此的任何解决方案。 最佳答案 在iPad上进行开发
我已经设置了MFMailComposeViewController,它在iPhone上正常工作,但是在iPad上崩溃了,并说: *** Terminating app due to uncaught
iPad:遍历UITableView中的每个单元格吗? 最佳答案 for (int section = 0; section < [tableView numberOfSections]; secti
我在这里寻找两个数字:纵向高度和横向高度。不要以厘米或英寸为单位回答,而以像素为单位。 最佳答案 纵向高度为 264,横向高度为 352。 我知道这是一个迟到的答案,但我自己也遇到了这个问题。 关于i
在我的应用程序中,我想播放Youtube URL(ipad)。我正在使用下面的代码。它只是向我显示一个白色屏幕 YouTube网址是:http://www.youtube.com/watch?v =
据我所知,iPad 使用 iPhone 操作系统,但屏幕分辨率与 iPhone 和 iPod touch 不同。许多网站可能必须更改其用户代理检测以适应 iPad。 那么,任何有权访问 iPad 或
我想预加载多个音频文件。为此,我尝试在JavaScript中创建多个Audio元素。 function loadAudio(){ audio1 = new Audio(); audio
我想使用适用于在所有最新 iPad 上查看的网页的字体。我找到了给定版本的 IOS 附带的字体列表。但这不是我想要的。我更喜欢给定 iPad 实际附带的字体列表,而不是 IOS 版本。如何解决这个问题
是否有可能拥有一个不在应用商店上架的 iPad 单独应用。该应用程序将在某些选定的成员中使用。因此它不需要进入应用商店,因为它不是供公众使用的。 最佳答案 那么有一些众所周知的可能性: Ad Hoc
子像素字体渲染如 ClearType显着提高字体显示分辨率并提高屏幕可读性。我如何对字体的子像素渲染进行编程(一般而言),以及如何在 iPad 上实现这一点(iOS 设备上的 C、C++ 或 Obje
我正在为 9.7 英寸 iPad 设计一个应用程序。我想知道是否有人对为更大的 iPad 设计的应用程序在 iPad mini 上的外观有任何经验?它会自动缩小,以某种方式在较小的屏幕上完美使用吗?还
我正在使用所有 UIKit,并且出于原型(prototype)设计的目的,我刚刚将所有逻辑插入了主 viewController。我在 viewDidLoad 中创建了一些 UIView,隐藏了一些,
我是一名优秀的程序员,十分优秀!