Attempting to get the GPS coordinates in a HTML5 web page viewed with Necessitas's port of QWebView. However it always responds with Not Supported.

试图在HTML5 web页面中使用必需的QWebView端口查看GPS坐标。然而,它总是响应不支持。

function load( )
{
   if ( navigator.geolocation )
   {
      alert( "Supported." );
   }
   else
   {
      alert( "Not Supported!" );
   }
}

I've altered the QWebPage to allow permissions:

我修改了qweb页面以允许权限:

BrowserWebPage::BrowserWebPage( QObject* parent ) : QWebPage( parent )
{
    connect( this,
             SIGNAL( featurePermissionRequested( QWebFrame*, QWebPage::Feature ) ),
             SLOT( permissionRequested( QWebFrame*, QWebPage::Feature ) ) );
}

void BrowserWebPage::permissionRequested( QWebFrame* frame, QWebPage::Feature feature )
{
    if ( feature == Geolocation )
    {
        setFeaturePermission( frame, feature, PermissionGrantedByUser );
    }
    else //denied
    {
        setFeaturePermission( frame, feature, PermissionDeniedByUser );
    }
}

And set the following permissions:

并设置以下权限:

android.permission.INTERNET

android.permission.INTERNET

android.permission.ACCESS_FINE_LOCATION

android.permission.ACCESS_FINE_LOCATION

android.permission.ACCESS_COARSE_LOCATION

android.permission.ACCESS_COARSE_LOCATION

EDIT

编辑

According to this page the GeoLocation API is present within the QtWebKit build.

根据这个页面,地理定位API出现在QtWebKit构建中。

http://trac.webkit.org/wiki/QtWebKitFeatures22

http://trac.webkit.org/wiki/QtWebKitFeatures22

DETAILS

细节

Phone: Galaxy Nexus

电话:Galaxy Nexus

Platform: Android 4.1.1 (SDK 14)

平台:Android 4.1.1 (SDK 14)

Framework: Qt 4.8.0 for Android armv7a

框架:Android armv7a的Qt 4.8.0

2 个解决方案

#1


1

I think you will have to set coarse location and internet permission because the fine location is only used for gps if im right. in any case having both is good cause if gps is not available the location over your internet connection will be used.

我认为你必须设置粗糙的位置和网络权限,因为好的位置只能用于gps,如果我是对的。在任何情况下,两者都有很好的原因,如果全球定位系统不可用,将使用您的互联网连接上的位置。

   <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
   <uses-permission android:name="android.permission.INTERNET" /> 

I don't really have experience with qtwebkit but this is the basics i can tell you.

我没有使用qtwebkit的经验,但这是我可以告诉你的基本知识。

更多相关文章

  1. js金额数字格式化实现代码(三位加逗号处理保留两位置小数)
  2. js“DOM事件”之鼠标事件、js的测试方法、js代码的放置位置
  3. 使用谷歌地图computeDistanceBetween获取最近的位置返回NaN
  4. Google Maps API v3:如何设置缩放级别和地图中心到用户提交的位置
  5. 拒绝获取不安全标题“位置”
  6. 将div停靠在窗口左侧并再次单击原始位置
  7. 如何在涉及css缩放时获取页面上的点击位置
  8. swiper 定位到指定页面或位置
  9. js获取点击事件的位置,兼容主流浏览器

随机推荐

  1. 设置ListView分割线
  2. Android 7.1 触摸事件代码跟踪
  3. android各版本对应的SDK level(包括androi
  4. [Android 特效] Android 通过流播放声音(
  5. Android写Logcat文件保存到SD卡
  6. android用Popup弹出窗(PopupWindow的使用
  7. 教你怎么配置Android的AndroidManifest.x
  8. android4.2上获取应用程序大小的变更点
  9. Android Widget程序源码
  10. Gradle sync failed: Gradle DSL method