示例#1
0
  @Override
  public void onLocationChanged(AMapLocation location) {
    if (location != null) {
      Double geoLat = location.getLatitude();
      Double geoLng = location.getLongitude();

      String str =
          ("定位成功:("
              + geoLng
              + ","
              + geoLat
              + ")"
              + "\n精    度    :"
              + location.getAccuracy()
              + "米"
              + "\n定位方式:"
              + location.getProvider());

      QuanApplication.LOCATION_LATITUDE = geoLat;
      QuanApplication.LOCATION_LONGITUDE = geoLng;
      QuanApplication.LOCATION_ADDRESS = location.getAddress();
      // LogUtils.e(str);

      updateNearByQuan();
    }
  }
示例#2
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 location) {
   if (location != null) {
     Double geoLat = location.getLatitude();
     Double geoLng = location.getLongitude();
     String cityCode = "";
     String desc = "";
     Bundle locBundle = location.getExtras();
     if (locBundle != null) {
       cityCode = locBundle.getString("citycode");
       desc = locBundle.getString("desc");
     }
     String str =
         ("定位成功:("
             + geoLng
             + ","
             + geoLat
             + ")"
             + "\n精    度    :"
             + location.getAccuracy()
             + "米"
             + "\n城市编码:"
             + cityCode
             + "\n位置描述:"
             + desc);
     Message msg = new Message();
     msg.obj = str;
     if (handler != null) {
       handler.sendMessage(msg);
     }
   }
 }
示例#4
0
 public void setOriLocation(AMapLocation loc) {
   if (loc != null) {
     mLocation.setLatitude(loc.getLatitude());
     mLocation.setLongitude(loc.getLongitude());
     Message msg = locationHandler.obtainMessage();
     msg.arg1 = MODE_CYCLE;
     msg.arg1 = -1;
     locationHandler.sendMessage(msg);
   }
 }
 @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); // 显示系统小蓝点
     }
   }
 }
示例#7
0
 @Override
 public void onLocationChanged(AMapLocation amapLocation) {
   if (mListener != null && amapLocation != null) {
     if (amapLocation != null && amapLocation.getAMapException().getErrorCode() == 0) {
       mListener.onLocationChanged(amapLocation);
     }
   }
 }
  /** 判断当前位置位于哪个校区 */
  private void judge_position() {
    if (mLocation.getLatitude() < 36.648152
        && mLocation.getLongitude() > 117.068195
        && mLocation.getLatitude() > 36.642666
        && mLocation.getLongitude() < 117.080217) {

      flag = 2; // 燕山校区
    } else if (mLocation.getLatitude() < 36.66187
        && mLocation.getLongitude() > 117.501132
        && mLocation.getLatitude() > 36.651857
        && mLocation.getLongitude() < 117.520319) {
      flag = 0; // 明水校区
    } else if (mLocation.getLatitude() < 36.674867
        && mLocation.getLongitude() > 117.370944
        && mLocation.getLatitude() > 36.665148
        && mLocation.getLongitude() < 117.380147) {
      flag = 1; // 圣井校区
    } else if (mLocation.getLatitude() < 36.631209
        && mLocation.getLongitude() > 117.019616
        && mLocation.getLatitude() > 36.619802
        && mLocation.getLongitude() < 117.026629) {
      flag = 3; // 舜耕校区
    }
    mMap.clear();
    this.flipper.setDisplayedChild(flag);
    mMap.animateCamera(
        CameraUpdateFactory.newLatLngZoom(position_schoolLatLngs[flag], zoom_current));
    startTextView.setText(null);
    endTextView.setText(null);
    isClickStart = true;
    isClickTarget = false;
    loadMap(flag + 2, true);
  }
示例#9
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) {

    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());
    }
  }
示例#11
0
  /**
   * 根据定位结果返回定位信息的字符串
   *
   * @param loc
   * @return
   */
  public static synchronized String getLocationStr(AMapLocation location) {
    if (null == location) {
      return null;
    }
    StringBuffer sb = new StringBuffer();
    // errCode等于0代表定位成功,其他的为定位失败,具体的可以参照官网定位错误码说明
    if (location.getErrorCode() == 0) {
      sb.append("定位成功" + "\n");
      sb.append("定位类型: " + location.getLocationType() + "\n");
      sb.append("经    度    : " + location.getLongitude() + "\n");
      sb.append("纬    度    : " + location.getLatitude() + "\n");
      sb.append("精    度    : " + location.getAccuracy() + "米" + "\n");
      sb.append("提供者    : " + location.getProvider() + "\n");

      if (location.getProvider().equalsIgnoreCase(android.location.LocationManager.GPS_PROVIDER)) {
        // 以下信息只有提供者是GPS时才会有
        sb.append("速    度    : " + location.getSpeed() + "米/秒" + "\n");
        sb.append("角    度    : " + location.getBearing() + "\n");
        // 获取当前提供定位服务的卫星个数
        sb.append("星    数    : " + location.getExtras().getInt("satellites", 0) + "\n");
      } else {
        // 供者是GPS时是没有以下信息的
        sb.append("国    家    : " + location.getCountry() + "\n");
        sb.append("省            : " + location.getProvince() + "\n");
        sb.append("市            : " + location.getCity() + "\n");
        sb.append("区            : " + location.getDistrict() + "\n");
        sb.append("地    址    : " + location.getAddress() + "\n");
      }
    } else {
      // 定位失败
      sb.append("定位为失败" + "\n");
      sb.append("错误码:" + location.getErrorCode() + "\n");
      sb.append("错误信息:" + location.getErrorInfo() + "\n");
      sb.append("错误描述:" + location.getLocationDetail() + "\n");
    }
    return sb.toString();
  }
示例#12
0
 @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());
   }
 }