Exemple #1
0
  /** 定位成功后回调函数 */
  @Override
  public void onLocationChanged(AMapLocation amapLocation) {
    if (mListener != null && amapLocation != null) {
      if (amapLocation.getAMapException().getErrorCode() == 0) {
        mListener.onLocationChanged(amapLocation); // 显示系统小蓝点
      }
    }

    final Double geoLat = amapLocation.getLatitude();
    final Double geoLng = amapLocation.getLongitude();

    searchNearby(geoLng.toString(), geoLat.toString());

    new Handler()
        .postDelayed(
            new Runnable() {
              public void run() {
                aMap.animateCamera(
                    CameraUpdateFactory.newCameraPosition(
                        new CameraPosition(new LatLng(geoLat, geoLng), 15, 30, 0)),
                    1000,
                    null);
              }
            },
            500);
  }
 @Override
 public void onLocationChanged(AMapLocation aMapLocation) {
   Log.i(TAG, "onLocationChanged");
   try {
     if (aMapLocation != null
         && aMapLocation.getAMapException() != null
         && aMapLocation.getAMapException().getErrorCode() == 0) {
       switch (type) {
         case JsConst.SHOW_LOCATION:
         case JsConst.CONTINUED:
           if (mLocationChangedListener != null) {
             mLocationChangedListener.onLocationChanged(aMapLocation); // 显示系统小蓝点
           }
           if (mListener != null) {
             mListener.onReceiveLocation(aMapLocation);
           }
           break;
         case JsConst.GET_LOCATION:
           if (mListener != null) {
             mListener.cbGetCurrentLocation(aMapLocation);
           }
           break;
       }
     }
   } catch (Exception e) {
     // e.printStackTrace();
   }
 }
 /**
  * 定位成功后回调函数
  *
  * @param aMapLocation
  */
 @Override
 public void onLocationChanged(AMapLocation aMapLocation) {
   if (null != mListener && null != aMapLocation) {
     if (aMapLocation.getAMapException().getErrorCode() == 0) {
       mListener.onLocationChanged(aMapLocation); // 显示系统小蓝点
     }
   }
 }
Exemple #4
0
 @Override
 public void onLocationChanged(AMapLocation amapLocation) {
   if (mListener != null && amapLocation != null) {
     if (amapLocation != null && amapLocation.getAMapException().getErrorCode() == 0) {
       mListener.onLocationChanged(amapLocation);
     }
   }
 }
Exemple #5
0
 @Override
 public void onLocationChanged(AMapLocation amapLocation) {
   if (amapLocation != null && amapLocation.getAMapException().getErrorCode() == 0) {
     // get geoinfo
     Double lati = amapLocation.getLatitude();
     Double logti = amapLocation.getLongitude();
     String address = amapLocation.getAddress();
     String province = amapLocation.getProvince();
     String country = amapLocation.getCountry();
     String city = amapLocation.getCity();
     String citycode = amapLocation.getCityCode();
     String district = amapLocation.getDistrict();
     String street = amapLocation.getStreet();
     float Accuracy = amapLocation.getAccuracy();
     String road = amapLocation.getRoad();
     geo.setLatitude(lati);
     geo.setLongitude(logti);
     geo.setAddress(address);
     geo.setProvince(province);
     geo.setCountry(country);
     geo.setCity(city);
     geo.setCitycode(citycode);
     geo.setDistrict(district);
     geo.setStreet(street);
     geo.setAccuracy(Accuracy);
     geo.setRoad(road);
     LogUtil.v(
         "Location info: ",
         lati + " " + logti + " " + address + " " + province + " " + country + " " + city + " "
             + citycode + " " + district + " " + street + " " + Accuracy + " " + road);
     loadNear();
   } else {
     this.stopLocation();
     onLoad();
     this.mTexthint.setClickable(true);
     this.mTexthint.setText(getString(R.string.get_no_position));
     LogUtil.v("NearFragment info: ", "enter onLocationChanged() + ERROR!");
     LogUtil.v(
         "NearFragment info : AmapErr",
         "Location ERR:" + amapLocation.getAMapException().getErrorCode());
   }
 }
 @Override
 public void onLocationChanged(AMapLocation amapLocation) {
   LogUtil.v(
       "MessboardActivity info: ", "enter onLocationChanged()!" + amapLocation.getLatitude());
   if (amapLocation != null && amapLocation.getAMapException().getErrorCode() == 0) {
     LogUtil.v("MessboardActivity info: ", "enter onLocationChanged()!" + " enter IF!");
     // get geoinfo
     Double lati = amapLocation.getLatitude();
     Double logti = amapLocation.getLongitude();
     String address = amapLocation.getAddress();
     String province = amapLocation.getProvince();
     String country = amapLocation.getCountry();
     String city = amapLocation.getCity();
     String citycode = amapLocation.getCityCode();
     String district = amapLocation.getDistrict();
     String street = amapLocation.getStreet();
     float Accuracy = amapLocation.getAccuracy();
     String road = amapLocation.getRoad();
     geo.setLatitude(lati);
     geo.setLongitude(logti);
     geo.setAddress(address);
     geo.setProvince(province);
     geo.setCountry(country);
     geo.setCity(city);
     geo.setCitycode(citycode);
     geo.setDistrict(district);
     geo.setStreet(street);
     geo.setAccuracy(Accuracy);
     geo.setRoad(road);
     LogUtil.v(
         "Location info: ",
         lati + " " + logti + " " + address + " " + province + " " + country + " " + city + " "
             + citycode + " " + district + " " + street + " " + Accuracy + " " + road);
     this.calculateDistance(lati, logti);
   } else {
     LogUtil.v("MessboardActivity info: ", "enter onLocationChanged() + ERROR!");
     Log.e("AmapErr", "Location ERR:" + amapLocation.getAMapException().getErrorCode());
   }
 }
  @Override
  public void onLocationChanged(AMapLocation aMapLocation) {

    if (aMapLocation != null) {
      //                this.aMapLocation = ;location// 判断超时机制
      Log.d(TAG, "err: " + aMapLocation.getAMapException().getErrorMessage());
      Double geoLat = aMapLocation.getLatitude();
      Double geoLng = aMapLocation.getLongitude();
      String cityCode = "";
      String desc = "";
      Bundle locBundle = aMapLocation.getExtras();
      if (locBundle != null) {
        cityCode = locBundle.getString("citycode");
        desc = locBundle.getString("desc");
      }
      String str =
          ("定位成功:("
              + geoLng
              + ","
              + geoLat
              + ")"
              + "\n精    度    :"
              + aMapLocation.getAccuracy()
              + "米"
              + "\n定位方式:"
              + aMapLocation.getProvider()
              + "\n定位时间:"
              + "  "
              + "\n城市编码:"
              + cityCode
              + "\n位置描述:"
              + desc
              + "\n省:"
              + aMapLocation.getProvince()
              + "\n市:"
              + aMapLocation.getCity()
              + "\n区(县):"
              + aMapLocation.getDistrict()
              + "\n区域编码:"
              + aMapLocation.getAdCode());
      searchText.setText(aMapLocation.getAddress());
    }
  }