折线不绘制我不使用wifi连接

时间:2014-05-02 17:55:21

标签: android wifi

当我不使用wifi连接时,折线不会画。 我正在尝试制作一个吸引自行车路线的应用程序。当我在wifi连接附近运行它时会绘制线条,但是当我在没有wifi的情况下运行它时,只有GPS连接时,我会看到纬度和经度,但是线条不会被绘制。非常感谢你。 我的代码是:

public void onConnected(Bundle dataBundle) {
        //Display the connection status
        makeText(this, "Connected", LENGTH_LONG).show();
       mCurrentLocationInicio = mLocationClient.getLastLocation();
       latitude = mCurrentLocationInicio.getLatitude();
       longitude = mCurrentLocationInicio.getLongitude();
       miUbicacionInicio = new LatLng(latitude, longitude);
       googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(miUbicacionInicio, 17));
       googleMap.addMarker(new MarkerOptions().title("Usted está aquí").snippet("Inicio").position(miUbicacionInicio));


       final LocationManager mLocationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
        final LocationListener mLocationListener = new LocationListener() {
         Context context = getApplicationContext();
           public void onLocationChanged(Location location) {
               Toast.makeText(context, "onLocationChanged", LENGTH_LONG).show();
               //PRIMER CAMBIO DE UBICACION
               Location location1 = mLocationClient.getLastLocation();
               double latitude1 = location1.getLatitude();
               double longitude1 = location1.getLongitude();
               LatLng ubicacionLocation1 = new LatLng(latitude1, longitude1);
               Toast.makeText(context, "Tomada location1", LENGTH_LONG).show();
               //IMPRIMO LA SITUACION DE LA LOCATION1:
               String msg = "Datos location1:" +
                       Double.toString(location1.getLatitude()) + ", " +
                       Double.toString(location1.getLongitude());
               Toast.makeText(context, msg, LENGTH_LONG).show();

               //IMPRIMO LA SITUACION DE i:
               String msgi = "Datos i:" +
                       Double.toString(location.getLatitude()) + ", " +
                       Double.toString(location.getLongitude());
               Toast.makeText(context, "Tomada situación i", LENGTH_LONG).show();
               Toast.makeText(context, msgi, LENGTH_LONG).show();

               PolylineOptions lineas;
               lineas = new PolylineOptions()
                       .add((ubicacionLocation1),
                            (new LatLng(location.getLatitude(),    location.getLongitude())))
                    .width(8).color(Color.BLUE);
               googleMap.addPolyline(lineas);
               Toast.makeText(context, "Pintadas localizaciones", LENGTH_LONG).show();
           }


           public void onStatusChanged(String provider, int status, Bundle extras) {
           }

           public void onProviderEnabled(String provider) {
           }

           public void onProviderDisabled(String provider) {
           }
       };
       mLocationManager.requestLocationUpdates(mLocationManager.GPS_PROVIDER, 15000,   0,mLocationListener);
       }

0 个答案:

没有答案