与cordova的地理位置没有结果

时间:2015-11-03 05:36:59

标签: android cordova geolocation telnet

我正在使用cordova开发混合应用程序。我目前正在开发Android应用程序。

我的 index.html 代码如下:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../favicon.ico">

    <title>Narrow Jumbotron Template for Bootstrap</title>

    <!-- Bootstrap core CSS -->
    <link href="./css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="./js/jumbotron-narrow.css" rel="stylesheet">

    <script src="cordova.js"></script>
    <script src="cordova_plugins.js"></script>

    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
    <body>

    <div class="container">
        <div class="header clearfix">
            <nav>
                <ul class="nav nav-pills pull-right">
                    <li role="presentation" class="active"><a href="#">Home</a></li>
                    <li role="presentation"><a href="#">About</a></li>
                    <li role="presentation"><a href="#">Contact</a></li>
                </ul>
            </nav>
            <h3 class="text-muted">Project name</h3>
        </div>

        <div class="jumbotron">
            <h1>Jumbotron heading</h1>
            <p class="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
            <p><a class="btn btn-lg btn-success" href="#" role="button">Sign up today</a></p>
        </div>

        <div class="row marketing">
            <div class="col-lg-6">
                <h4>Subheading</h4>
                <p>Click the button to get your coordinates.</p>

                <button class="btn btn-lg btn-succes" onclick="getLocation()">Try It</button>

                <p id="demo"></p>


            </div>


        </div>

        <footer class="footer">
            <p>&copy; Company 2014</p>
        </footer>

        <script>
var x = document.getElementById("demo");

function getLocation() {
    if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(showPosition,showError);
    } else {
        x.innerHTML = "Geolocation is not supported by this browser.";
    }
}

function showPosition(position) {
    x.innerHTML="Latitude: " + position.coords.latitude +
    "<br>Longitude: " + position.coords.longitude;
}

function showError(error) {
    switch(error.code) {
        case error.PERMISSION_DENIED:
            x.innerHTML = "User denied the request for Geolocation."
            break;
        case error.POSITION_UNAVAILABLE:
            x.innerHTML = "Location information is unavailable."
            break;
        case error.TIMEOUT:
            x.innerHTML = "The request to get user location timed out."
            break;
        case error.UNKNOWN_ERROR:
            x.innerHTML = "An unknown error occurred."
            break;
    }
}
</script>

    </div> <!-- /container -->


    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
    </body>
</html>

我在android清单文件中使用以下权限。

<uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />

并在配置文件中使用此

 <plugin name="Geolocation" value="org.apache.cordova.GeoBroker" />

使用端口5554的telnet会话和geo fix 120 120命令修复我的Android模拟器(Android工作室)上的地理定位位置。我好好回来。

它曾经工作,但后来搞砸了一些东西,它停止了工作,直到现在我没有发现我搞砸了什么并且撤消了我最近的stepps并没有解决它。

当我点击我的日志显示的按钮时。 11-03 05:47:28.809 2079-2079 / com.example.xhtml W / art:尝试删除非JNI本地引用,转储线程 11-03 05:47:28.941 2079-2079 / com.example.xhtml W / art:尝试删除非JNI本地引用,转储线程 11-03 05:47:29.090 2079-2079 / com.example.xhtml W / art:尝试删除非JNI本地引用,转储线程

有时我也会得到 11-03 05:47:16.239 2079-2096 / com.example.xhtml我/艺术:背景粘性并发标记扫描GC释放15(272B)AllocSpace对象,0(0B)LOS对象,0%免费,14MB / 14MB,暂停17.517ms总计37.382ms

0 个答案:

没有答案