当前位置: 首页>>代码示例>>Java>>正文


Java AMapLocation.getCity方法代码示例

本文整理汇总了Java中com.amap.api.location.AMapLocation.getCity方法的典型用法代码示例。如果您正苦于以下问题:Java AMapLocation.getCity方法的具体用法?Java AMapLocation.getCity怎么用?Java AMapLocation.getCity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.amap.api.location.AMapLocation的用法示例。


在下文中一共展示了AMapLocation.getCity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setCity

import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
/**
 * 设置当前城市
 * @param amapLocation
 */
@Subscribe(threadMode = ThreadMode.BACKGROUND)
public void setCity(AMapLocation amapLocation) {
    if(amapLocation!=null){
        this.city = amapLocation.getCity();
    }
}
 
开发者ID:Vicent9920,项目名称:MyMap,代码行数:11,代码来源:PoiSearchActivity.java

示例2: onLocationChanged

import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
/**
     * 实现定位
     * @param amapLocation
     */
    @Override
    public void onLocationChanged(AMapLocation amapLocation) {
        if (mListener != null && amapLocation != null) {
            if (amapLocation != null
                    &&amapLocation.getErrorCode() == 0) {

                if(isFirstTime){//只要第一次的数据,当然,也可以在这里关闭定位
//                    mlocationClient.stopLocation();//停止定位
                    mListener.onLocationChanged(amapLocation);// 显示系统小蓝点
                    lvHolder.title = "[位置]";
                    lvHolder.address = amapLocation.getProvider()+amapLocation.getCity()+amapLocation.getStreet()+amapLocation.getStreetNum();
                    lvHolder.lp = new LatLonPoint(amapLocation.getLatitude(),amapLocation.getLongitude());
                    mEndMarker.setPosition(new LatLng(amapLocation.getLatitude(),amapLocation.getLongitude()));
                    data.add(0,lvHolder);
                    doSearchQuery();

                }

            } else {
                String errText = "定位失败," + amapLocation.getErrorCode()+ ": " + amapLocation.getErrorInfo();
                Log.e("AmapErr",errText);
            }
        }
    }
 
开发者ID:Vicent9920,项目名称:MyMap,代码行数:29,代码来源:PiclocationActivity.java

示例3: initLocation

import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
/**
 * 初始化百度地图
 */
private void initLocation() {
    AMapLocation location = locationClient.getLastKnownLocation();
    if (location != null) {
        Log.d(TAG, "getLastKnownLocation success");
        mLongitude = location.getLongitude();
        mLatitude = location.getLatitude();
        city = location.getCity();
        country = location.getCountry();
        Log.d("XLight", String.format("long:%s,latitude:%s,ciry:%s,country:%s", mLongitude, mLatitude, city, country));
        //请求天气信息
        updateLocationInfo();
    } else {
        // 启动定位
        locationClient.startLocation();
    }
}
 
开发者ID:Datatellit,项目名称:xlight_android_native,代码行数:20,代码来源:GlanceMainFragment.java

示例4: onLocationChanged

import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation loc) {
    if (null != loc && loc.getErrorCode() == 0) {
        //解析定位结果
        mLongitude = loc.getLongitude();
        mLatitude = loc.getLatitude();
        city = loc.getCity();
        country = loc.getCountry();
        Log.i("XLight", String.format("long:%s,latitude:%s,city:%s,country:%s", mLongitude, mLatitude, city, country));
        //请求天气信息
        updateLocationInfo();
        locationClient.stopLocation();
    } else {
        // 定位失败,显示提示
        Log.e("XLight", "location Error, ErrCode:"
                + loc.getErrorCode() + ", errInfo:"
                + loc.getErrorInfo());
        getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                ToastUtil.showToast(getActivity(), R.string.open_gps);
            }
        });
    }
}
 
开发者ID:Datatellit,项目名称:xlight_android_native,代码行数:26,代码来源:GlanceMainFragment.java

示例5: onLocationChanged

import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
    if (aMapLocation != null) {
        if (aMapLocation.getErrorCode() == 0) {
            mCity = aMapLocation.getCity();
            mSwipeRefreshLayout.setEnabled(true);
            mSwipeRefreshLayout.post(new Runnable() {
                @Override
                public void run() {
                    mSwipeRefreshLayout.setRefreshing(true);
                }
            });
            getWeatherData(mCity);
        }
        //定位失败,通过ErrCode(错误码)信息来确定失败的原因,errInfo是错误信息
        else {
            SnackBarUtil.showSnackBar(aMapLocation.getErrorInfo(), mSwipeRefreshLayout, getActivity());
        }
    }
}
 
开发者ID:xiarunhao123,项目名称:PureNews,代码行数:21,代码来源:WeatherFragment.java

示例6: onLocationChanged

import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
    public void onLocationChanged(AMapLocation aLocation) {
        if (aLocation != null) {
            // mALocation = aLocation;
            /**
             * 获取城市的编码
             */
            //cityCode = aLocation.getCityCode();
            String city = aLocation.getCity();
            if (!TextUtils.isEmpty(city)) {
                datas.set(0, city);
                mRouteAdapter.notifyDataSetChanged();
            }

//            StringBuffer sb = new StringBuffer(256);
//            sb.append(aLocation.getCity());
//            if (sb.toString() != null && sb.toString().length() > 0) {
//                String lngCityName = sb.toString();
//
//            }

        }
    }
 
开发者ID:LegendKe,项目名称:MyTravelingDiary,代码行数:24,代码来源:ChooseRouteActivity.java

示例7: onLocationChanged

import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
    public void onLocationChanged(AMapLocation aLocation) {
        if (aLocation != null) {
            // mALocation = aLocation;
            /**
             * 获取城市的编码
             */
            //cityCode = aLocation.getCityCode();
            String city = aLocation.getCity();
            String add = aLocation.getPoiName();
            //Log.i("TAG", "------>" + aLocation.getPoiName() + "--->" + aLocation.getDistrict() + "------>" + aLocation.getProvider());
            if (!TextUtils.isEmpty(city) && !TextUtils.isEmpty(add)) {
                mAddress.setText(city + " · " + add);
                address = city + " · " + add;
            }

//            StringBuffer sb = new StringBuffer(256);
//            sb.append(aLocation.getCity());
//            if (sb.toString() != null && sb.toString().length() > 0) {
//                String lngCityName = sb.toString();
//
//            }

        }
    }
 
开发者ID:LegendKe,项目名称:MyTravelingDiary,代码行数:26,代码来源:CaptionAddActivity.java

示例8: onLocationChanged

import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
/**
 * 定位成功后回调函数
 */
@Override
public void onLocationChanged(AMapLocation aLocation) {
    if (mListener != null && aLocation != null) {
        mALocation = aLocation;
        /**
         * 获取城市的编码
         */
        cityCode = aLocation.getCityCode();
        city = aLocation.getCity();
        mListener.onLocationChanged(aLocation);// 显示系统小蓝点
        //获取经纬度
        BigDecimal latitude = new BigDecimal(aLocation.getLatitude());
        x = latitude.setScale(8, BigDecimal.ROUND_DOWN).doubleValue();
        BigDecimal longitude = new BigDecimal(aLocation.getLongitude());
        y = longitude.setScale(8, BigDecimal.ROUND_DOWN).doubleValue();
        //搜索框内容为空时执行周边搜索方法,有内容时执行关键词搜索方法
        final String searchKey = mSearch.getText().toString().trim();
        if (TextUtils.isEmpty(searchKey)) {
            PoiCheckEnd(aLocation, "");
        } else {
            initListener();
        }
    }
}
 
开发者ID:LegendKe,项目名称:MyTravelingDiary,代码行数:28,代码来源:ChooseLocationActivity.java

示例9: onLocationChanged

import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
/**
 * 定位监听回掉
 */
@Override
public void onLocationChanged(AMapLocation amapLocation) {
    if (mListener != null && amapLocation != null) {
        if (amapLocation.getErrorCode() == 0) {
            mCity = amapLocation.getCity();
            mCityTextView.setText(mCity);

            mPresenter.searchWeatherRecord(getContext(), amapLocation.getCity());

            mListener.onLocationChanged(amapLocation);// 显示系统小蓝点
        } else {
            String errText = "定位失败," + amapLocation.getErrorCode() + ": " + amapLocation.getErrorInfo();
            Log.e("AmapErr", errText);
            //mLocationErrText.setVisibility(View.VISIBLE);
            //mLocationErrText.setText(errText);
        }
    }
}
 
开发者ID:Alex-ZHOU,项目名称:VMAndroid,代码行数:22,代码来源:RecordFragment.java

示例10: getLocationCityStr

import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
/**
 * 根据定位结果返回定位信息的字符串
 *
 * @param location
 * @return
 */
public synchronized static String getLocationCityStr(AMapLocation location) {
    if (null == location) {
        return null;
    }

    StringBuffer sb = new StringBuffer();
    //errCode等于0代表定位成功,其他的为定位失败,具体的可以参照官网定位错误码说明
    if (location.getErrorCode() == 0) {
        String tmpSb = location.getCity();
        sb.append(tmpSb.substring(0, tmpSb.length() - 1));
    } else {
        //定位失败
        sb.append("定位失败" + "\n");
        sb.append("错误码:" + location.getErrorCode() + "\n");
        sb.append("错误信息:" + location.getErrorInfo() + "\n");
        sb.append("错误描述:" + location.getLocationDetail() + "\n");
    }
    
    Log.d("AMapUtils", sb.toString());
    return sb.toString();
}
 
开发者ID:absentm,项目名称:myapplication,代码行数:28,代码来源:AMapUtils.java

示例11: onLocationChanged

import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
    if (aMapLocation != null) {
        if (aMapLocation.getErrorCode() == 0) {
            presenter = new OnShownMoviePresenter(this, aMapLocation.getCity());
            presenter.start();
        } else {
            presenter = new OnShownMoviePresenter(this,"杭州");
            presenter.start();
            ToastUtil.makeTextShort(getActivity(), getString(R.string.error_location) + " code:" + aMapLocation.getErrorCode()
                    + " msg:" + aMapLocation.getErrorInfo());
        }
    }
}
 
开发者ID:HStanN,项目名称:TakeRest,代码行数:15,代码来源:OnShownMovieFragment.java

示例12: 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

示例13: onLocationChanged

import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
    Message message = mHandler.obtainMessage();
    message.obj = aMapLocation.getCity();
    message.what = UPDATELOCATION_MESSAGE;
    Log.e(TAG, "onLocationChanged: " +  aMapLocation.getCity());
    message.sendToTarget();
}
 
开发者ID:kaiwk,项目名称:Today,代码行数:9,代码来源:WeatherActionsCreatort.java

示例14: onLocationChanged

import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation location) {
	// this.location = location;
	if (mListener != null && location != null) {
		mListener.onLocationChanged(location);
	}
	if (!locationChange) {
		if (location != null) {
			LatLng latlng = new LatLng(location.getLatitude(),
					location.getLongitude());
			CameraPosition cameraPosition = new CameraPosition.Builder()
					.target(latlng).zoom(18).build();
			map.animateCamera(CameraUpdateFactory
					.newCameraPosition(cameraPosition));
			if (latlng != null) {
				String keyWord = location.getCity();
				PoiSearch.Query query = new PoiSearch.Query(
						keyWord,
						"汽车服务|汽车销售|汽车维修|摩托车服务|餐饮服务|购物服务|生活服务|体育休闲服务|医疗保健服务|风景名胜|商务住宅|政府机构及社会团体|科教文化服务|交通设施服务|金融保险服务|公司企业|道路附属设施|地名地址信息|公共设施",
						"");// (第三个参数)这里可以传空字符串,空字符串代表全国在全国范围内进行搜索
				query.setPageNum(1);
				query.setPageSize(40);
				PoiSearch poiSearch = new PoiSearch(getActivity(), query);
				poiSearch.setBound(new SearchBound(new LatLonPoint(
						latlng.latitude, latlng.longitude), 3000));
				poiSearch.setOnPoiSearchListener(this);
				poiSearch.searchPOIAsyn();
			}
			locationChange = true;
		}
	}

}
 
开发者ID:wangcantian,项目名称:Mobile-Office,代码行数:34,代码来源:MapFragment.java

示例15: onLocationChanged

import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation location) {
	if (location != null && location.getAMapException().getErrorCode() == 0) {
		this.aMapLocation = location;// 判断超时机制
		cityName = location.getCity();
		String cityCode = location.getCityCode();
		main_tv_zipcode.setText(cityName + "\n" + "电话区号" + cityCode);
	} else {
		Log.e("code", ""+location.getAMapException().getErrorCode());
		Log.e("location", ""+(location == null));
		main_tv_zipcode.setText("定位失败...");
	}
}
 
开发者ID:PengSen,项目名称:work_sen,代码行数:14,代码来源:MainActivity.java


注:本文中的com.amap.api.location.AMapLocation.getCity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。