本文整理汇总了Java中com.baidu.mapapi.search.geocode.GeoCoder类的典型用法代码示例。如果您正苦于以下问题:Java GeoCoder类的具体用法?Java GeoCoder怎么用?Java GeoCoder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GeoCoder类属于com.baidu.mapapi.search.geocode包,在下文中一共展示了GeoCoder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initBaiduMap
import com.baidu.mapapi.search.geocode.GeoCoder; //导入依赖的package包/类
private void initBaiduMap() {
mBaiduMap = mIMapView.getBaiduMap();
//获取地图对象控制器
mBaiduMap.setBuildingsEnabled(true);//设置显示楼体
mBaiduMap.setMapStatus(MapStatusUpdateFactory.zoomTo(19f));//设置地图状态
mUiSettings = mBaiduMap.getUiSettings();
mUiSettings.setZoomGesturesEnabled(true);
mUiSettings.setScrollGesturesEnabled(true);
mUiSettings.setRotateGesturesEnabled(true);
mUiSettings.setOverlookingGesturesEnabled(true);
mUiSettings.setCompassEnabled(true);
MapStatus ms = new MapStatus.Builder().overlook(30).build();
MapStatusUpdate u = MapStatusUpdateFactory.newMapStatus(ms);
mBaiduMap.animateMapStatus(u, 1000);
// 初始化搜索模块
mSearch = GeoCoder.newInstance();
mSearch.setOnGetGeoCodeResultListener(this);
}
示例2: initView
import com.baidu.mapapi.search.geocode.GeoCoder; //导入依赖的package包/类
@Override
public void initView() {
initData();
// 初始化搜索模块,注册事件监听
mSearch = GeoCoder.newInstance();
mSearch.setOnGetGeoCodeResultListener(this);
View view = View.inflate(this, R.layout.head_city_list, null);
gridView = (GridView) view.findViewById(R.id.gridview_hot);
gridViewAdapter = new CityGridViewAdapter(this, hotCity);
gridView.setAdapter(gridViewAdapter);
gridView.setSelector(new ColorDrawable(Color.TRANSPARENT));
sideBar = (SideBar) findViewById(R.id.sidrbar);
dialog = (TextView) findViewById(R.id.dialog);
sideBar.setTextView(dialog);
sortListView = (ListView) findViewById(R.id.country_lvcountry);
sortListView.addHeaderView(view);
adapter = new SortAdapter(this, SourceDateList);
sortListView.setAdapter(adapter);
clearEditText = (ClearCityEditText) findViewById(R.id.filter_edit);
}
示例3: calculatecRoute
import com.baidu.mapapi.search.geocode.GeoCoder; //导入依赖的package包/类
private void calculatecRoute(int netmode) {
locations.clear();
GeoCoder startSearch = null; // 由地址到经纬度的搜索模块
GeoCoder endSearch = null; // 由地址到经纬度的搜索模块
// 初始化搜索模块,注册事件监听
startSearch = GeoCoder.newInstance();
startSearch.setOnGetGeoCodeResultListener(startPlaceGeo);
endSearch = GeoCoder.newInstance();
endSearch.setOnGetGeoCodeResultListener(endPlaceGeo);
//获取输入的起终点
String start = startPlace.getText().toString();
String end = endPlace.getText().toString();
startSearch.geocode(new GeoCodeOption().city("济南").address(start));
endSearch.geocode(new GeoCodeOption().city("济南").address(end));
}
示例4: onCreate
import com.baidu.mapapi.search.geocode.GeoCoder; //导入依赖的package包/类
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_geocoder);
CharSequence titleLable = "地理编码功能";
setTitle(titleLable);
// 地图初始化
mMapView = (MapView) findViewById(R.id.bmapView);
mBaiduMap = mMapView.getMap();
mBaiduMap.setOnMarkerClickListener(mOnMarkerClickListener);
// 初始化搜索模块,注册事件监听
mSearch = GeoCoder.newInstance();
mSearch.setOnGetGeoCodeResultListener(this);
mCenterLatLng = MyUtils.getLlByIntent(getIntent());
MyUtils.initMapCenter(mCenterLatLng, mBaiduMap);
mMarkerA = MyUtils.addOverLayToMap(
BitmapDescriptorFactory.fromResource(R.drawable.icon_marka),
mCenterLatLng, mBaiduMap);
}
示例5: initMap
import com.baidu.mapapi.search.geocode.GeoCoder; //导入依赖的package包/类
private void initMap() {
flag = 0;
// 地图初始化
mBaiduMap = mMapView.getMap();
// 初始化搜索模块,注册事件监听
mGeoCoderSearch = GeoCoder.newInstance();
mGeoCoderSearch.setOnGetGeoCodeResultListener(this);
// Geo搜索
mGeoCoderSearch.geocode(new GeoCodeOption().city(mEndCity).address(mEndAddr));
DialogUtils.showLoadDialog(this, "正在查找商家位置...");
}
示例6: begin
import com.baidu.mapapi.search.geocode.GeoCoder; //导入依赖的package包/类
public void begin() {
mGeoCoder = GeoCoder.newInstance();
mGeoCoder.setOnGetGeoCodeResultListener(this);
switch (mQueryType) {
case QUERY_BEGIN_ADDRESS:
mGeoCoder.reverseGeoCode(new ReverseGeoCodeOption().location(mRouteData.getBeginLatlng()));
break;
case QUERY_END_ADDRESS:
mGeoCoder.reverseGeoCode(new ReverseGeoCodeOption().location(mRouteData.getEndLatlng()));
break;
}
}
示例7: onCreate
import com.baidu.mapapi.search.geocode.GeoCoder; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
activityList.add(this);
SDKInitializer.initialize(getApplicationContext());
setContentView(R.layout.road_nav);
intent=getIntent();
address=intent.getStringExtra("address");
lLat=intent.getDoubleExtra("Lat", 0.1);
lLng=intent.getDoubleExtra("Lng",0.1);
mWgsNaviBtn = (Button) findViewById(R.id.wgsNaviBtn);
mWgsNaviBtn1 = (Button) findViewById(R.id.wgsNaviBtn1);
// mGcjNaviBtn = (Button) findViewById(R.id.gcjNaviBtn);
// mBdmcNaviBtn = (Button) findViewById(R.id.bdmcNaviBtn);
// mDb06ll = (Button) findViewById(R.id.mDb06llNaviBtn);
button = (Button) findViewById(R.id.Sgeocode);
button1 = (Button) findViewById(R.id.Egeocode);
button2= (Button) findViewById(R.id.DSgeocode);
editCity = (EditText) findViewById(R.id.Scity);
editGeoCodeKey = (EditText) findViewById(R.id.Sgeocodekey);
EndeditCity = (EditText) findViewById(R.id.Ecity);
EndeditGeoCodeKey = (EditText) findViewById(R.id.Egeocodekey);
DeditCity = (EditText) findViewById(R.id.Dcity);
DeditGeoCodeKey = (EditText) findViewById(R.id.Dgeocodekey);
add= (TextView) findViewById(R.id.tv_add);
add.setText(address);
mSearch = GeoCoder.newInstance();
mSearch.setOnGetGeoCodeResultListener(this);
initListener();
if (initDirs()) {
initNavi();
}
}
示例8: onCreate
import com.baidu.mapapi.search.geocode.GeoCoder; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
application = (DeviceMessageApplication) getActivity().getApplication();
//地图覆盖物初始化
bitmapDescriptorMan = BitmapDescriptorFactory.fromResource(R.mipmap.map_portrait_mark_man_circle);
bitmapDescriptorWoman = BitmapDescriptorFactory.fromResource(R.mipmap.map_portrait_mark_woman_circle);
bmStart = BitmapDescriptorFactory.fromResource(R.mipmap.icon_start);
bmEnd = BitmapDescriptorFactory.fromResource(R.mipmap.icon_end);
option = new MarkerOptions();
geoCoder = GeoCoder.newInstance();
geoCoder.setOnGetGeoCodeResultListener(this);
reverseGeoCodeOption = new ReverseGeoCodeOption();
//管理员权限用户信息弹窗初始化
viewOverlayItem = View.inflate(getContext(), R.layout.item_map_addoverlay_radarnearby_admin, null);
tvAddOverlayItemUserID = (TextView) viewOverlayItem.findViewById(R.id.tvAddOverlayItemUserID);
imageViewAddOverlayItem = (ImageView) viewOverlayItem.findViewById(R.id.imageViewAddOverlayItem);
tvAddOverlayGeoCoder = (TextView) viewOverlayItem.findViewById(R.id.tvAddOverlayGeoCoder);
tvAddOverlayItemDistance = (TextView) viewOverlayItem.findViewById(R.id.tvAddOverlayItemDistance);
tvAddOverlayItemLatlng = (TextView) viewOverlayItem.findViewById(R.id.tvAddOverlayItemLatlng);
layoutAddOverlayRadarNearbyItem = (LinearLayout) viewOverlayItem.findViewById(R.id.layoutAddOverlayRadarNearbyItem);
btnAddOverlayItemTrackQuery = (Button) viewOverlayItem.findViewById(R.id.btnAddOverlayItemTrackQuery);
btnAddOverlayItemGeoFencePlace = (Button) viewOverlayItem.findViewById(R.id.btnAddOverlayItemGeoFencePlace);
btnAddOverlayItemTrackQuery.setOnClickListener(this);
btnAddOverlayItemGeoFencePlace.setOnClickListener(this);
}
示例9: initBaiduMap
import com.baidu.mapapi.search.geocode.GeoCoder; //导入依赖的package包/类
private void initBaiduMap() {
//��ͼ��ʼ��
mMapView = (MapView) findViewById(R.id.bmapView);
mBaiduMap = mMapView.getMap();
//�������ż���
mBaiduMap.setMaxAndMinZoomLevel(18, 13);
//ע��SDK �㲥������
IntentFilter iFilter = new IntentFilter();
iFilter.addAction(SDKInitializer.SDK_BROADTCAST_ACTION_STRING_PERMISSION_CHECK_ERROR);
iFilter.addAction(SDKInitializer.SDK_BROADCAST_ACTION_STRING_NETWORK_ERROR);
receiver = new BaiduReceiver();
registerReceiver(receiver, iFilter);
Intent intent = getIntent();
String type = intent.getStringExtra("type");
if("select".equals(type)) {
initTopBarForBoth("�", R.drawable.btn_login_selector, new onRightImageButtonClickListener() {
@Override
public void onClick() {
gotoChatPage();
}
});
mHeaderLayout.getRightImageButton().setClickable(false);
initLocClient();
} else {// �鿴��ǰλ��
initTopBarForLeft("�");
Bundle b = intent.getExtras();
LatLng latlng = new LatLng(b.getDouble("latitude"), b.getDouble("longtitude"));//ά����ǰ�������ں�
mBaiduMap.setMapStatus(MapStatusUpdateFactory.newLatLng(latlng));
//��ʾ��ǰλ��ͼ��
OverlayOptions ooA = new MarkerOptions().position(latlng).icon(bdgeo).zIndex(9);
mBaiduMap.addOverlay(ooA);
}
mSearch = GeoCoder.newInstance();
mSearch.setOnGetGeoCodeResultListener(this);
}
示例10: onCreate
import com.baidu.mapapi.search.geocode.GeoCoder; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SDKInitializer.initialize(getApplicationContext());
this.context = this;
setContentView(R.layout.activity_navigation);
initView();
// 初始化搜索模块,注册事件监听
mSearch = GeoCoder.newInstance();
mSearch.setOnGetGeoCodeResultListener(this);
}
示例11: initBaiduMap
import com.baidu.mapapi.search.geocode.GeoCoder; //导入依赖的package包/类
private void initBaiduMap() {
// 地图初始化
mMapView = (MapView) findViewById(R.id.bmapView);
mBaiduMap = mMapView.getMap();
// 设置缩放级别
mBaiduMap.setMaxAndMinZoomLevel(18, 13);
// 注册 SDK 广播监听者
IntentFilter iFilter = new IntentFilter();
iFilter.addAction(SDKInitializer.SDK_BROADTCAST_ACTION_STRING_PERMISSION_CHECK_ERROR);
iFilter.addAction(SDKInitializer.SDK_BROADCAST_ACTION_STRING_NETWORK_ERROR);
mReceiver = new BaiduReceiver();
registerReceiver(mReceiver, iFilter);
Intent intent = getIntent();
String type = intent.getStringExtra("type");
if (type.equals("select")) {// 选择发送位置
// initTopBarForBoth("位置", R.drawable.btn_login_selector, "发送", new
// onRightImageButtonClickListener() {
// @Override
// public void onClick() {
// // TODO Auto-generated method stub
// gotoChatPage();
// }
// });
// mHeaderLayout.getRightImageButton().setEnabled(false);
initLocClient();
} else {// 查看当前位置
// initTopBarForLeft("位置");
Bundle b = intent.getExtras();
LatLng latlng = new LatLng(b.getDouble("latitude"), b.getDouble("longtitude"));// 维度在前,经度在后
mBaiduMap.setMapStatus(MapStatusUpdateFactory.newLatLng(latlng));
// 显示当前位置图标
OverlayOptions ooA = new MarkerOptions().position(latlng).icon(bdgeo).zIndex(9);
mBaiduMap.addOverlay(ooA);
}
mSearch = GeoCoder.newInstance();
mSearch.setOnGetGeoCodeResultListener(this);
}
示例12: initStartAddress
import com.baidu.mapapi.search.geocode.GeoCoder; //导入依赖的package包/类
@Override
public void initStartAddress() {
BDLocation location = new BDLocation();
location.setLatitude(address.getLatitude());
location.setLongitude(address.getLongitude());
location.setRadius(address.getRadius());
location.setSpeed(address.getSpeed());
location.setSatelliteNumber(address.getSatelliteNumber());
// location = LocationClient.getBDLocationInCoorType(location, BDLocation.BDLOCATION_GCJ02_TO_BD09LL);
//更新家和公司视图
updateCompany();
updateHome();
final GeoCoder geoCoder = GeoCoder.newInstance();
/* 设置地理编码查询监听者 */
final BDLocation finalLocation = location;
geoCoder.setOnGetGeoCodeResultListener(new OnGetGeoCoderResultListener() {
@Override
public void onGetGeoCodeResult(GeoCodeResult geoCodeResult) {
}
@Override
public void onGetReverseGeoCodeResult(ReverseGeoCodeResult r) {
List<PoiInfo> ls = r.getPoiList();
if (ls != null && ls.size() > 0) {
initAddress = new BaiduAddress();
// String myLocation;
setBaiduAddressFromPoiInfo(initAddress, ls.get(0));
// myLocation = initAddress.getName();
initAddress.setAddress(address.getAddressDetail());
initAddress.setLatitude(finalLocation.getLatitude());
initAddress.setLongitude(finalLocation.getLongitude());
if (TextUtils.isEmpty(initAddress.getCity()))
initAddress.setCity(address.getCity());
BaiduAddress myStartAddr = new BaiduAddress();
myStartAddr.setLatitude(initAddress.getLatitude());
myStartAddr.setLongitude(initAddress.getLongitude());
myStartAddr.setName("我的位置" + "(" + initAddress.getName() + ")" + "附近");
if (mSetPointView.getStartAddrText().startsWith("我的位置")) {
myStartAddr.setRemark("出发地");
myStartAddr.setId(null);
myStartAddr.setFavoritedTime(null);
mAppConfig.startAddress = myStartAddr;
}
//设置默认回家和去公司的出发地址
// mAppConfig.myAddress = myLocation;
// updateCompany();
// updateHome();
//由init进入该方法时不触发导航
updateStart(false);
updateEnd(false);
updateHistoryList();
geoCoder.destroy();
}
}
});
geoCoder.reverseGeoCode(new ReverseGeoCodeOption().
location(new LatLng(location.getLatitude(), location.getLongitude())));
}
示例13: init
import com.baidu.mapapi.search.geocode.GeoCoder; //导入依赖的package包/类
private void init() {
mSearch = GeoCoder.newInstance();
mSearch.setOnGetGeoCodeResultListener(this);
mMapView = (MapView) findViewById(R.id.map);
mBaiduMap = mMapView.getMap();
mMapView.showZoomControls(false);
entityName = getImei(getApplicationContext()); //手机Imei值的获取,用来充当实体名
client = new LBSTraceClient(getApplicationContext()); //实例化轨迹服务客户端
trace = new Trace(getApplicationContext(), serviceId, entityName, traceType); //实例化轨迹服务
client.setInterval(gatherInterval, packInterval); //设置位置采集和打包周期
}
示例14: initLocationAndSearch
import com.baidu.mapapi.search.geocode.GeoCoder; //导入依赖的package包/类
private void initLocationAndSearch() {
//location
mLocationClient = new LocationClient(getApplicationContext()); //声明LocationClient类
mLocationClient.registerLocationListener(this); //注册监听函数
LocationClientOption option = new LocationClientOption();
option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy
);//可选,默认高精度,设置定位模式,高精度,低功耗,仅设备
option.setCoorType("bd09ll");//可选,默认gcj02,设置返回的定位结果坐标系
int span = 1000;
option.setScanSpan(span);//可选,默认0,即仅定位一次,设置发起定位请求的间隔需要大于等于1000ms才是有效的
option.setIsNeedAddress(true);//可选,设置是否需要地址信息,默认不需要
option.setOpenGps(true);//可选,默认false,设置是否使用gps
option.setLocationNotify(true);//可选,默认false,设置是否当GPS有效时按照1S/1次频率输出GPS结果
option.setIsNeedLocationDescribe(true);//可选,默认false,设置是否需要位置语义化结果,可以在BDLocation.getLocationDescribe里得到,结果类似于“在北京天安门附近”
option.setIsNeedLocationPoiList(true);//可选,默认false,设置是否需要POI结果,可以在BDLocation.getPoiList里得到
option.setIgnoreKillProcess(false);//可选,默认true,定位SDK内部是一个SERVICE,并放到了独立进程,设置是否在stop的时候杀死这个进程,默认不杀死
option.SetIgnoreCacheException(false);//可选,默认false,设置是否收集CRASH信息,默认收集
option.setEnableSimulateGps(false);//可选,默认false,设置是否需要过滤GPS仿真结果,默认需要
mLocationClient.setLocOption(option);
//search
mPoiSearch = PoiSearch.newInstance();
mPoiSearch.setOnGetPoiSearchResultListener(new MyPoiSearchListener());
mNearbySearchOption = new PoiNearbySearchOption()
.radius(5000)
.pageNum(1)
.pageCapacity(20)
.sortType(PoiSortType.distance_from_near_to_far);
////////////////
mGeoCoder = GeoCoder.newInstance();
mGeoCoder.setOnGetGeoCodeResultListener(new OnGetGeoCoderResultListener() {
@Override
public void onGetGeoCodeResult(GeoCodeResult geoCodeResult) {
Log.e(TAG, "onGetGeoCodeResult: " + geoCodeResult.toString());
}
@Override
public void onGetReverseGeoCodeResult(ReverseGeoCodeResult reverseGeoCodeResult) {
Log.e(TAG, "onGetReverseGeoCodeResult: " + reverseGeoCodeResult.toString());
}
});
}
示例15: initBaiduMap
import com.baidu.mapapi.search.geocode.GeoCoder; //导入依赖的package包/类
private void initBaiduMap() {
// ��ͼ��ʼ��
mMapView = (MapView) findViewById(R.id.bmapView);
mBaiduMap = mMapView.getMap();
mBaiduMap.setMaxAndMinZoomLevel(18, 13);
IntentFilter iFilter = new IntentFilter();
iFilter.addAction(SDKInitializer.SDK_BROADTCAST_ACTION_STRING_PERMISSION_CHECK_ERROR);
iFilter.addAction(SDKInitializer.SDK_BROADCAST_ACTION_STRING_NETWORK_ERROR);
mReceiver = new BaiduReceiver();
registerReceiver(mReceiver, iFilter);
Intent intent = getIntent();
String type = intent.getStringExtra("type");
if (type.equals("select")) {
initTopBarForBoth("位置", R.drawable.base_action_bar_true_bg_selector,
new onRightImageButtonClickListener() {
@Override
public void onClick() {
// TODO Auto-generated method stub
gotoChatPage();
}
});
mHeaderLayout.getRightImageButton().setEnabled(false);
initLocClient();
} else {
initTopBarForLeft("位置");
Bundle b = intent.getExtras();
LatLng latlng = new LatLng(b.getDouble("latitude"), b.getDouble("longtitude"));//ά����ǰ�������ں�
mBaiduMap.setMapStatus(MapStatusUpdateFactory.newLatLng(latlng));
//��ʾ��ǰλ��ͼ��
OverlayOptions ooA = new MarkerOptions().position(latlng).icon(bdgeo).zIndex(9);
mBaiduMap.addOverlay(ooA);
}
mSearch = GeoCoder.newInstance();
mSearch.setOnGetGeoCodeResultListener(this);
}