<i id='7aMvI'><tr id='7aMvI'><dt id='7aMvI'><q id='7aMvI'><span id='7aMvI'><b id='7aMvI'><form id='7aMvI'><ins id='7aMvI'></ins><ul id='7aMvI'></ul><sub id='7aMvI'></sub></form><legend id='7aMvI'></legend><bdo id='7aMvI'><pre id='7aMvI'><center id='7aMvI'></center></pre></bdo></b><th id='7aMvI'></th></span></q></dt></tr></i><div id='7aMvI'><tfoot id='7aMvI'></tfoot><dl id='7aMvI'><fieldset id='7aMvI'></fieldset></dl></div>
<tfoot id='7aMvI'></tfoot>
  • <small id='7aMvI'></small><noframes id='7aMvI'>

    <legend id='7aMvI'><style id='7aMvI'><dir id='7aMvI'><q id='7aMvI'></q></dir></style></legend>

      <bdo id='7aMvI'></bdo><ul id='7aMvI'></ul>

        在地图中显示当前位置时获得 0.0 的纬度和经度

        时间:2023-09-02
        <legend id='YTQUo'><style id='YTQUo'><dir id='YTQUo'><q id='YTQUo'></q></dir></style></legend>
        <i id='YTQUo'><tr id='YTQUo'><dt id='YTQUo'><q id='YTQUo'><span id='YTQUo'><b id='YTQUo'><form id='YTQUo'><ins id='YTQUo'></ins><ul id='YTQUo'></ul><sub id='YTQUo'></sub></form><legend id='YTQUo'></legend><bdo id='YTQUo'><pre id='YTQUo'><center id='YTQUo'></center></pre></bdo></b><th id='YTQUo'></th></span></q></dt></tr></i><div id='YTQUo'><tfoot id='YTQUo'></tfoot><dl id='YTQUo'><fieldset id='YTQUo'></fieldset></dl></div>

        <small id='YTQUo'></small><noframes id='YTQUo'>

          <tbody id='YTQUo'></tbody>
        • <tfoot id='YTQUo'></tfoot>

              <bdo id='YTQUo'></bdo><ul id='YTQUo'></ul>
                  本文介绍了在地图中显示当前位置时获得 0.0 的纬度和经度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在使用以下代码来获取我的当前位置.但我面临的问题是,纬度和经度总是返回 0.0.我已经打开手机中的GPS设置并设置了所有权限.但我仍然面临这个问题.

                  I am using the following code to get my current location. But the problem I am facing is, it always returns 0.0 for latitude and longitude. I have turned on the GPS settings in the phone and set all the permissions. But still I am facing this.

                  locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
                  
                  customLocationListener = new CustomLocationListener();
                  
                  locationManager.requestLocationUpdates(
                  
                          LocationManager.GPS_PROVIDER,
                  
                          0,
                  
                          0,
                  
                          customLocationListener);
                  
                  class CustomLocationListener implements LocationListener{ ............
                  
                        public void onLocationChanged(Location argLocation) { 
                  
                           if(location != null) {     
                  
                          int latitude=(int)(argLocation.getLatitude()*1E6);   
                  
                          int longitude=(int)(argLocation.getLongitude()*1E6);
                  
                  
                                }
                         } ........ }
                  

                  你们中有人知道为什么吗?

                  Do any one of you know why?

                  注意:我的活动扩展 MapActivity 而不是位置监听器

                  Note : My activity extends MapActivity not Location Listener

                  推荐答案

                  试试这个方法

                  locationManager = (LocationManager) context
                                  .getSystemService(Context.LOCATION_SERVICE);
                  
                  
                          Criteria locationCritera = new Criteria();
                          String providerName = locationManager.getBestProvider(locationCritera,
                                  true);
                          if(providerName!=null)
                              location = locationManager.getLastKnownLocation(providerName);
                  
                          locationListener = new MyLocationListener();
                  
                          locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0,
                                  0, locationListener);
                  

                  在 mylocationlistener 中设置你的位置对象

                  in mylocationlistener set your location object

                  private class MyLocationListener implements LocationListener {
                  
                      public void onLocationChanged(Location loc) {
                  
                          if (loc != null) {
                              location = loc; 
                  
                          }
                      }
                  
                      public void onProviderDisabled(String provider) {
                  
                      }
                  
                      public void onProviderEnabled(String provider) {
                      }
                  
                      public void onStatusChanged(String provider, int status, Bundle extras) {
                      }
                  }
                  

                  这篇关于在地图中显示当前位置时获得 0.0 的纬度和经度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:无法在 Android 的浏览器上使用 Javascript 获取 GPS 下一篇:iOS 6 破坏了 webapps 中的 GeoLocation (apple-mobile-web-

                  相关文章

                  最新文章

                  <tfoot id='ldF1U'></tfoot>
                  <legend id='ldF1U'><style id='ldF1U'><dir id='ldF1U'><q id='ldF1U'></q></dir></style></legend>
                • <i id='ldF1U'><tr id='ldF1U'><dt id='ldF1U'><q id='ldF1U'><span id='ldF1U'><b id='ldF1U'><form id='ldF1U'><ins id='ldF1U'></ins><ul id='ldF1U'></ul><sub id='ldF1U'></sub></form><legend id='ldF1U'></legend><bdo id='ldF1U'><pre id='ldF1U'><center id='ldF1U'></center></pre></bdo></b><th id='ldF1U'></th></span></q></dt></tr></i><div id='ldF1U'><tfoot id='ldF1U'></tfoot><dl id='ldF1U'><fieldset id='ldF1U'></fieldset></dl></div>
                  1. <small id='ldF1U'></small><noframes id='ldF1U'>

                      <bdo id='ldF1U'></bdo><ul id='ldF1U'></ul>