當前位置: 首頁>>代碼示例>>Java>>正文


Java AMapLocation.getProvince方法代碼示例

本文整理匯總了Java中com.amap.api.location.AMapLocation.getProvince方法的典型用法代碼示例。如果您正苦於以下問題:Java AMapLocation.getProvince方法的具體用法?Java AMapLocation.getProvince怎麽用?Java AMapLocation.getProvince使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.amap.api.location.AMapLocation的用法示例。


在下文中一共展示了AMapLocation.getProvince方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onLocationChanged

import com.amap.api.location.AMapLocation; //導入方法依賴的package包/類
@Override
public void onLocationChanged(AMapLocation amapLocation) {
    if (amapLocation != null && amapLocation.getErrorCode() == 0) {
        Double latitude = amapLocation.getLatitude();
        Double longitude = amapLocation.getLongitude();
        boolean hasAccuracy = amapLocation.hasAccuracy();
        float accuracy = amapLocation.getAccuracy();
        String address = amapLocation.getAddress();
        String province = amapLocation.getProvince();
        String road = amapLocation.getRoad();
        float speed = amapLocation.getSpeed();
        float bearing = amapLocation.getBearing();
        int satellites = amapLocation.getExtras().getInt("satellites", 0);
        long time = amapLocation.getTime();

        JSONObject jo = new JSONObject();
        try {
            jo.put("latitude", latitude);
            jo.put("longitude", longitude);
            jo.put("hasAccuracy", hasAccuracy);
            jo.put("accuracy", accuracy);
            jo.put("address", address);
            jo.put("province", province);
            jo.put("road", road);
            jo.put("speed", speed);
            jo.put("bearing", bearing);
            jo.put("satellites", satellites);
            jo.put("time", time);

        } catch (JSONException e) {
            jo = null;
            e.printStackTrace();
        }
        callbackContext.success(jo);
    } else {
        callbackContext.error(amapLocation.getErrorInfo());
    }
}
 
開發者ID:starwander,項目名稱:cordova-plugin-amap-navi,代碼行數:39,代碼來源:AMapLoc.java

示例2: onLocationChanged

import com.amap.api.location.AMapLocation; //導入方法依賴的package包/類
@Override
public void onLocationChanged(AMapLocation amapLocation) {
    if (amapLocation != null && amapLocation.getAMapException().getErrorCode() == 0) {
        //獲取位置信息
        location = amapLocation.getAddress();
        city = amapLocation.getProvince() + "·" + amapLocation.getCity() + amapLocation.getDistrict();

    }
}
 
開發者ID:jiangzehui,項目名稱:xmpp,代碼行數:10,代碼來源:Location.java

示例3: onLocationChanged

import com.amap.api.location.AMapLocation; //導入方法依賴的package包/類
/**
*獲取到位置信息
*@author invinjun
*created at 2016/7/1 15:31
*/
//以下為後者的舉例:

@Override
public void onLocationChanged(AMapLocation aMapLocation) {
    if (aMapLocation != null) {
        if (aMapLocation.getErrorCode() == 0) {
            //定位成功回調信息,設置相關消息
            aMapLocation.getLocationType();//獲取當前定位結果來源,如網絡定位結果,詳見定位類型表
            aMapLocation.getLatitude();//獲取緯度
            aMapLocation.getLongitude();//獲取經度
            aMapLocation.getAccuracy();//獲取精度信息
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date date = new Date(aMapLocation.getTime());
            df.format(date);//定位時間
            aMapLocation.getAddress();//地址,如果option中設置isNeedAddress為false,則沒有此結果,網絡定位結果中會有地址信息,GPS定位不返回地址信息。
            aMapLocation.getCountry();//國家信息
            if (mCityName ==null|| mCityName.equals("")){
                mCityName =aMapLocation.getProvince();//省信息
            }
            Log.e("AmapError","location success, CityCode:"
                    + aMapLocation.getCityCode() + ", Province:"
                    + aMapLocation.getProvince());
            SPUtils.setParam(context, Constants.USER_INFO, Constants.USER_LOCATION_CODE, aMapLocation.getCityCode());
            SPUtils.setParam(context, Constants.USER_INFO, Constants.USER_LOCATION_NAME, aMapLocation.getCity().substring(0,aMapLocation.getCity().length()-1));
        } else {
            SPUtils.setParam(context, Constants.USER_INFO, Constants.USER_LOCATION_CODE, "010");
            SPUtils.setParam(context, Constants.USER_INFO, Constants.USER_LOCATION_NAME, "北京");
            //顯示錯誤信息ErrCode是錯誤碼,errInfo是錯誤信息,詳見錯誤碼表。
            Log.e("AmapError","location Error, ErrCode:"
                    + aMapLocation.getErrorCode() + ", errInfo:"
                    + aMapLocation.getErrorInfo());
        }
    }
}
 
開發者ID:woniukeji,項目名稱:jianguo,代碼行數:40,代碼來源:SplashActivity.java

示例4: onLocationChanged

import com.amap.api.location.AMapLocation; //導入方法依賴的package包/類
/**
   * ��λ�ص�����������λ��ɺ���ô˷���
   * @param aMapLocation
   */
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
	if(listener!=null && aMapLocation!=null) {
          listener.onLocationChanged(aMapLocation);// ��ʾϵͳС����
          if (aMapLocation.getErrorCode() == 0) {
              //��λ�ɹ��ص���Ϣ�����������Ϣ
              aMapLocation.getLocationType();//��ȡ��ǰ��λ�����Դ�������綨λ����������λ���ͱ�
              aMapLocation.getLatitude();//��ȡ����
              aMapLocation.getLongitude();//��ȡγ��;
              aMapLocation.getAccuracy();//��ȡ������Ϣ
              SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
              Date date = new Date(aMapLocation.getTime());
              df.format(date);//��λʱ��
              aMapLocation.getAddress();//��ַ�����option������isNeedAddressΪfalse����û�д˽��
              aMapLocation.getCountry();//������Ϣ
              aMapLocation.getProvince();//ʡ��Ϣ
              aMapLocation.getCity();//������Ϣ
              aMapLocation.getDistrict();//������Ϣ
              aMapLocation.getRoad();//�ֵ���Ϣ
              aMapLocation.getCityCode();//�����
              aMapLocation.getAdCode();//��������
          		} // ��������ñ�־λ����ʱ���϶���ͼʱ�����᲻�Ͻ���ͼ�ƶ�����ǰ��λ��
          		if (isFirstLoc) {
       	   
               //�������ż���
               aMap.moveCamera(CameraUpdateFactory.zoomTo(17));
               //����ͼ�ƶ�����λ��
               aMap.moveCamera(CameraUpdateFactory.changeLatLng(new LatLng(  
                       aMapLocation.getLatitude(), aMapLocation.getLongitude())));  
               //�����λ��ť �ܹ�����ͼ�������ƶ�����λ��
               listener.onLocationChanged(aMapLocation);
               //���ͼ��
               //aMap.addMarker(getMarkerOptions(aMapLocation));
               //��ȡ��λ��Ϣ
               StringBuffer buffer = new StringBuffer();
               buffer.append(aMapLocation.getCountry() + "," + aMapLocation.getProvince() + "," + aMapLocation.getCity() + "," + aMapLocation.getProvince() + "," + aMapLocation.getDistrict() + "," + aMapLocation.getStreet() + "," + aMapLocation.getStreetNum());
               Messages = buffer.toString();
               Toast.makeText(getActivity().getApplicationContext(), buffer.toString(), Toast.LENGTH_LONG).show();
               isFirstLoc = false;
          	}
       } else {
           //��ʾ������ϢErrCode�Ǵ����룬errInfo�Ǵ�����Ϣ������������
           Log.e("AmapError", "location Error, ErrCode:"
                   + aMapLocation.getErrorCode() + ", errInfo:"
                   + aMapLocation.getErrorInfo());
           Toast.makeText(getActivity().getApplicationContext(), "��λʧ��", Toast.LENGTH_LONG).show();
       }
     
	}
 
開發者ID:Edward7Zhang,項目名稱:oneKey2Alarm,代碼行數:54,代碼來源:map_Located.java

示例5: onLocationChanged

import com.amap.api.location.AMapLocation; //導入方法依賴的package包/類
/**
 * 定位成功後回調函數
 */
@Override
public void onLocationChanged(AMapLocation amapLocation) {
    MyAmapLocation =amapLocation;
    if (amapLocation != null) {
        if (amapLocation.getErrorCode() == 0) {
            //定位成功回調信息,設置相關消息
            amapLocation.getLocationType();//獲取當前定位結果來源,如網絡定位結果,詳見官方定位類型表
            amapLocation.getLatitude();//獲取緯度
            amapLocation.getLongitude();//獲取經度
            amapLocation.getAccuracy();//獲取精度信息
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA);
            Date date = new Date(amapLocation.getTime());
            df.format(date);//定位時間
            amapLocation.getAddress();//地址,如果option中設置isNeedAddress為false,則沒有此結果,網絡定位結果中會有地址信息,GPS定位不返回地址信息。
            amapLocation.getCountry();//國家信息
            amapLocation.getProvince();//省信息
            amapLocation.getCity();//城市信息
            amapLocation.getDistrict();//城區信息
            amapLocation.getStreet();//街道信息
            amapLocation.getStreetNum();//街道門牌號信息
            amapLocation.getCityCode();//城市編碼
            amapLocation.getAdCode();//地區編碼

            // 如果不設置標誌位,此時再拖動地圖時,它會不斷將地圖移動到當前的位置
            aMap.moveCamera(CameraUpdateFactory.zoomTo(17)); //設置縮放級別
            aMap.moveCamera(CameraUpdateFactory.changeLatLng(new LatLng(amapLocation.getLatitude(), amapLocation.getLongitude())));//將地圖移動到定位點
            mListener.onLocationChanged(amapLocation);//點擊定位按鈕 能夠將地圖的中心移動到定位點
            //aMap.addMarker(getMarkerOptions(amapLocation));//添加圖釘
            StringBuffer buffer = new StringBuffer();//獲取定位信息
            buffer.append(amapLocation.getCountry() + "" + amapLocation.getProvince() + "" + amapLocation.getCity() + "" + amapLocation.getProvince() + "" + amapLocation.getDistrict() + "" + amapLocation.getStreet() + "" + amapLocation.getStreetNum());
            Toast.makeText(getApplicationContext(), buffer.toString(), Toast.LENGTH_LONG).show();
        } else {
            //顯示錯誤信息ErrCode是錯誤碼,errInfo是錯誤信息,詳見錯誤碼表。
            Log.e("AmapError", "location Error, ErrCode:"
                    + amapLocation.getErrorCode() + ", errInfo:"
                    + amapLocation.getErrorInfo());

            Toast.makeText(getApplicationContext(), "定位失敗", Toast.LENGTH_LONG).show();
        }
    }
}
 
開發者ID:BoldFei,項目名稱:Zmap_test,代碼行數:45,代碼來源:MainActivity.java

示例6: onLocationChanged

import com.amap.api.location.AMapLocation; //導入方法依賴的package包/類
@Override
        public void onLocationChanged(AMapLocation aMapLocation) {
            if (aMapLocation != null) {
                if (aMapLocation.getErrorCode() == 0) {
                    //可在其中解析amapLocation獲取相應內容。
//                    aMapLocation.getLocationType();//獲取當前定位結果來源,如網絡定位結果,詳見定位類型表
                    double latitude = aMapLocation.getLatitude();//獲取緯度
                    double longitude = aMapLocation.getLongitude();//獲取經度
                    aMapLocation.getAccuracy();//獲取精度信息
                    aMapLocation.getAddress();//地址,如果option中設置isNeedAddress為false,則沒有此結果,網絡定位結果中會有地址信息,GPS定位不返回地址信息。
                    aMapLocation.getCountry();//國家信息
                    String province = aMapLocation.getProvince();//省信息
                    String city = aMapLocation.getCity();//城市信息
                    String district = aMapLocation.getDistrict();//城區信息
                    aMapLocation.getStreet();//街道信息
                    aMapLocation.getStreetNum();//街道門牌號信息
                    aMapLocation.getCityCode();//城市編碼
                    aMapLocation.getAdCode();//地區編碼
                    aMapLocation.getAoiName();//獲取當前定位點的AOI信息
                    aMapLocation.getBuildingId();//獲取當前室內定位的建築物Id
                    aMapLocation.getFloor();//獲取當前室內定位的樓層
                    Log.d("map", "onLocationChanged: " + aMapLocation.toString());
                    //獲取定位時間
                    @SuppressLint("SimpleDateFormat") SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    Date date = new Date(aMapLocation.getTime());
                    df.format(date);
                    LocationEntity locationEntity = new LocationEntity();
                    locationEntity.setProvince(province);
                    locationEntity.setPosLng(String.valueOf(longitude));
                    locationEntity.setPosLat(String.valueOf(latitude));
                    locationEntity.setCity(city);
                    locationEntity.setDistrict(district);
                    mSendLocation.sendLocation(locationEntity);
                } else {
                    mSendLocation.sendLocation(null);
                    //定位失敗時,可通過ErrCode(錯誤碼)信息來確定失敗的原因,errInfo是錯誤信息,詳見錯誤碼表。
                    Log.e("AmapError", "location Error, ErrCode:"
                            + aMapLocation.getErrorCode() + ", errInfo:"
                            + aMapLocation.getErrorInfo());
                }

            } else {
                mSendLocation.sendLocation(null);
            }
            if (mLocationClient.isStarted()){

                mLocationClient.stopLocation();
            }
        }
 
開發者ID:lzcmagic,項目名稱:daliylife,代碼行數:50,代碼來源:AMapUtils.java

示例7: onLocationChanged

import com.amap.api.location.AMapLocation; //導入方法依賴的package包/類
@Override
public void onLocationChanged(AMapLocation amapLocation) {
    if (amapLocation != null) {
        if (amapLocation.getErrorCode() == 0) {
            //定位成功回調信息,設置相關消息
            amapLocation.getLocationType();//獲取當前定位結果來源,如網絡定位結果,詳見官方定位類型表
            mLatitude = amapLocation.getLatitude();//獲取緯度
            mLongitude = amapLocation.getLongitude();//獲取經度
            amapLocation.getAccuracy();//獲取精度信息
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date date = new Date(amapLocation.getTime());
            df.format(date);//定位時間
            amapLocation.getAddress();//地址,如果option中設置isNeedAddress為false,則沒有此結果,網絡定位結果中會有地址信息,GPS定位不返回地址信息。
            amapLocation.getCountry();//國家信息
            amapLocation.getProvince();//省信息
            mCity = amapLocation.getCity();//城市信息
            amapLocation.getDistrict();//城區信息
            amapLocation.getStreet();//街道信息
            amapLocation.getStreetNum();//街道門牌號信息
            amapLocation.getCityCode();//城市編碼
            amapLocation.getAdCode();//地區編碼

            titleCenterTv.setText(amapLocation.getCity());
            lp = new LatLonPoint(mLongitude, mLatitude);
            Log.i(LOG, ">>>>> " + mCity + ", " + mLongitude + ", " + mLatitude);

            // 如果不設置標誌位,此時再拖動地圖時,它會不斷將地圖移動到當前的位置
            if (isFirstLoc) {
                //設置縮放級別
                aMap.moveCamera(CameraUpdateFactory.zoomTo(17));
                //將地圖移動到定位點
                aMap.moveCamera(CameraUpdateFactory.changeLatLng(new LatLng(amapLocation.getLatitude(), amapLocation.getLongitude())));
                //點擊定位按鈕 能夠將地圖的中心移動到定位點
                mListener.onLocationChanged(amapLocation);
                //添加圖釘
                mMarker = aMap.addMarker(getMarkerOptions(amapLocation));

                isFirstLoc = false;
            }

        } else {
            //顯示錯誤信息ErrCode是錯誤碼,errInfo是錯誤信息,詳見錯誤碼表。
            Log.e("AmapError", "location Error, ErrCode:"
                    + amapLocation.getErrorCode() + ", errInfo:"
                    + amapLocation.getErrorInfo());

            Toast.makeText(FindMapAroundAty.this, "定位失敗", Toast.LENGTH_LONG).show();
        }
    }
}
 
開發者ID:absentm,項目名稱:myapplication,代碼行數:51,代碼來源:FindMapAroundAty.java

示例8: onLocationChanged

import com.amap.api.location.AMapLocation; //導入方法依賴的package包/類
@Override
public void onLocationChanged(AMapLocation amapLocation) {
	if (mDataSave == null) {
		mDataSave = new LocationDataSave();
	}
	if (amapLocation != null) {
		if (amapLocation.getErrorCode() == 0) {
			// 定位成功回調信息,設置相關消息
			amapLocation.getLocationType();// 獲取當前定位結果來源,如網絡定位結果,詳見定位類型表
			double lat = amapLocation.getLatitude();// 獲取緯度
			double lng = amapLocation.getLongitude();// 獲取經度
			amapLocation.getAccuracy();// 獲取精度信息
			SimpleDateFormat df = new SimpleDateFormat(
					"yyyy-MM-dd HH:mm:ss");
			Date date = new Date(amapLocation.getTime());
			df.format(date);// 定位時間
			StringTool.DateToString1(new Date(amapLocation.getTime()));
			String address = amapLocation.getAddress();// 地址,如果option中設置isNeedAddress為false,則沒有此結果,網絡定位結果中會有地址信息,GPS定位不返回地址信息。
			amapLocation.getCountry();// 國家信息
			amapLocation.getProvince();// 省信息
			amapLocation.getCity();// 城市信息
			amapLocation.getDistrict();// 城區信息
			amapLocation.getStreet();// 街道信息
			amapLocation.getStreetNum();// 街道門牌號信息
			amapLocation.getCityCode();// 城市編碼
			amapLocation.getAdCode();// 地區編碼
			String mLocationAOI = amapLocation.getAoiName();// 獲取當前定位點的AOI信息
			if (!isFirst) {
				mDataSave.setAddress(address);
				mDataSave.setLat(lat);
				mDataSave.setLng(lng);
				mDataSave.setLocationAOI(mLocationAOI);
				if (mLocationAOI != null && !mLocationAOI.equals("")) {
					storeName.setText(mLocationAOI);
				} else {
					storeName.setText(amapLocation.getCity()
							+ amapLocation.getDistrict()
							+ amapLocation.getStreet()
							+ amapLocation.getStreetNum());
				}
				addressName.setText(address);
				getView().initLatLng(lat, lng);
				isFirst = true;
			}
		} else {
			// 顯示錯誤信息ErrCode是錯誤碼,errInfo是錯誤信息,詳見錯誤碼表。
			Log.e("AmapError", "location Error, ErrCode:"
					+ amapLocation.getErrorCode() + ", errInfo:"
					+ amapLocation.getErrorInfo());
		}
	}
}
 
開發者ID:wangcantian,項目名稱:Mobile-Office,代碼行數:53,代碼來源:CheckInPresenter.java


注:本文中的com.amap.api.location.AMapLocation.getProvince方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。