Android:HERE地图定位管理器getposition()总是返回Lat:17976931348623200 ..,Lon:17976931348623200

时间:2017-04-15 03:23:13

标签: android here-api

我是HERE地图的新手,目前正试图从定位管理器,getlocation()方法获取当前用户位置,但我的代码始终返回以下信息

com.nokia.maps.GeoPositionImpl [坐标=会有地理座标[纬度= -179769313486232000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000经度= -179769313486232000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000海拔= 1073741824.000000有效值= FALSE]]

以下是我的代码:

     protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            //requestPermissions();

            // Search for the Map Fragment
            final MapFragment mapFragment = (MapFragment)
                    getFragmentManager().findFragmentById(R.id.mapfragment);
    // initialize the Map Fragment and
    // retrieve the map that is associated to the fragment
            mapFragment.init(new OnEngineInitListener() {
                @Override
                public void onEngineInitializationCompleted(
                        OnEngineInitListener.Error error) {
                    if (error == OnEngineInitListener.Error.NONE) {
    // now the map is ready to be used
                        map = mapFragment.getMap();

                        onMapFragmentInitializationCompleted();
      } else {
                        System.out.println("ERROR: Cannot initialize MapFragment");
                        System.out.println("ERROR: Cannot initialize Map Fragment: " + error.toString());
                    }
                }
            });

       }




     private void onMapFragmentInitializationCompleted() {
            PositioningManager posManager;
             MapContainer placesContainer = null;
            // retrieve a reference of the map from the map fragment
           // map = mapFragment.getMap();
            // start the position manager
            posManager = PositioningManager.getInstance();
            posManager.start(PositioningManager.LocationMethod.GPS_NETWORK);

            GeoPosition position = posManager.getPosition();
            GeoCoordinate cor = position.getCoordinate();

            // Set a pedestrian friendly map scheme
            map.setMapScheme(Map.Scheme.PEDESTRIAN_DAY);

            // Display position indicator
            map.getPositionIndicator().setVisible(true);

            placesContainer = new MapContainer();
            map.addMapObject(placesContainer);

            // Set the map center coordinate to the current position
            map.setCenter(posManager.getPosition().getCoordinate(), Map.Animation.NONE);
            map.setZoomLevel(14);
        }


Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.benz.event.navigation">
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="navigation"
        android:hardwareAccelerated="true"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">


        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <meta-data android:name="com.here.android.maps.appid" android:value="MY ID"/>
        <meta-data android:name="com.here.android.maps.apptoken" android:value="MY TOKEN"/>
        <meta-data android:name="com.here.android.maps.license.key" android:value="MY KEY"/>



        <!--
           Embed the HERE Map Service.
          For more information, see the HERE SDK Developer's Guide
      -->
        <service
            android:name="com.here.android.mpa.service.MapService"
            android:label="HereMapService"
            android:process="global.Here.Map.Service.v2"
            android:exported="true" >
            <intent-filter>
                <action android:name="com.here.android.mpa.service.MapService" >
                </action>
            </intent-filter>
        </service>



    </application>





</manifest>

任何帮助/提示都会节省我的一天

由于

1 个答案:

答案 0 :(得分:0)

有效= FALSE表示您的设备没有GPS锁定。您的设备是否在室内且无法获得位置?其次,请检查您的申请是否具有定位权限。

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