百度地图移动到指定点 本帖最后由 zhangjie201412 于 2012-11-22 11:10:41 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 sercher.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub //mSearch.suggestionSearch(address.getText().toString()); mSearch.poiSearchInCity(address.getText().toString(),address.getText().toString()); if(!mydrawer.isOpened()) { mydrawer.open(); goal.setText(address.getText().toString()); cityname=address.getText().toString(); } } });。mBMapMan = new BMapManager(getApplication()); mBMapMan.init("D34BB8CA4F7C3947ACBCC6A186D4BC03F5916492", null); super.initMapActivity(mBMapMan); mMapView = (MapView)findViewById(R.id.mapView); mylayout=(RelativeLayout)findViewById(R.id.set); mylayout.setOnTouchListener(this); // mMapView.setOnTouchListener(this); address.setOnTouchListener(this); mMapView.setBuiltInZoomControls(true); //设置在缩放动画过程中也显示overlay,默认为不绘制 mMapView.setDrawOverlayWhenZooming(true); // 初始化搜索模块,注册事件监听 mSearch = new MKSearch(); mSearch.init(mBMapMan, new MKSearchListener(){ public void onGetPoiResult(MKPoiResult res, int type, int error) { // 错误号可参考MKEvent中的定义 if (error != 0 || res == null) { Toast.makeText(SetAddress.this, "抱歉,未找到结果", Toast.LENGTH_LONG).show(); return; } // 将地图移动到第一个POI中心点 if (res.getCurrentNumPois() > 0) { // 将poi结果显示到地图上 PoiOverlay poiOverlay = new PoiOverlay(SetAddress.this, mMapView); poiOverlay.setData(res.getAllPoi()); mMapView.getOverlays().clear(); mMapView.getOverlays().add(poiOverlay); mMapView.invalidate(); mMapView.getController().animateTo(res.getPoi(0).pt); } else if (res.getCityListNum() > 0) { mSearch.poiSearchInCity(res.getCityListInfo(0).city,address.getText().toString()); String strInfo = "在"; for (int i = 0; i < res.getCityListNum(); i++) { strInfo += res.getCityListInfo(i).city; strInfo += ","; } strInfo += "找到结果"; Toast.makeText(SetAddress.this, strInfo, Toast.LENGTH_LONG).show(); } } public void onGetDrivingRouteResult(MKDrivingRouteResult res, int error) { } public void onGetTransitRouteResult(MKTransitRouteResult res, int error) { } public void onGetWalkingRouteResult(MKWalkingRouteResult res, int error) { } public void onGetAddrResult(MKAddrInfo res, int error) { } public void onGetBusDetailResult(MKBusLineResult result, int iError) { } public void onGetSuggestionResult(MKSuggestionResult res, int arg1) { // TODO Auto-generated method stub if (arg1 != 0 || res == null) { Toast.makeText(SetAddress.this, "抱歉,未找到结果", Toast.LENGTH_LONG).show(); return; } int nSize = res.getSuggestionNum(); mStrSuggestions = new String[nSize]; for (int i = 0; i < nSize; i++) { mStrSuggestions[i] = res.getSuggestion(i).city + res.getSuggestion(i).key; } // ArrayAdapter<String> suggestionString = new ArrayAdapter<String>(.this, android.R.layout.simple_list_item_1,mStrSuggestions); // mSuggestionList.setAdapter(suggestionString); Toast.makeText(SetAddress.this, "suggestion callback", Toast.LENGTH_LONG).show(); } public void onGetRGCShareUrlResult(String arg0, int arg1) { // TODO Auto-generated method stub } }); } 关于新浪微博的API LayoutInflater的inflate方法 请教android的安全软件开发 android应用层开发和嵌入式开发的区别 为什么有的客户端软件只用wifi就可以定位?大多数好像都不行? 怎么在smali中修改才能注释java代码中的一行 商场地图 Bitmap与Drawable转化问题 Android Studio新建项目只生成了空文件夹 从网络请求的图片如何在方法里转成Bitmap并返回 绝对定位下ImageView重绘Bitmap的问题 RadioButton能把字体放在按钮的前面吗?
public void onClick(View v) {
// TODO Auto-generated method stub
//mSearch.suggestionSearch(address.getText().toString());
mSearch.poiSearchInCity(address.getText().toString(),address.getText().toString());
if(!mydrawer.isOpened())
{
mydrawer.open();
goal.setText(address.getText().toString());
cityname=address.getText().toString();
}
}
});
。
mBMapMan = new BMapManager(getApplication());
mBMapMan.init("D34BB8CA4F7C3947ACBCC6A186D4BC03F5916492", null);
super.initMapActivity(mBMapMan);
mMapView = (MapView)findViewById(R.id.mapView);
mylayout=(RelativeLayout)findViewById(R.id.set);
mylayout.setOnTouchListener(this);
// mMapView.setOnTouchListener(this);
address.setOnTouchListener(this);
mMapView.setBuiltInZoomControls(true);
//设置在缩放动画过程中也显示overlay,默认为不绘制
mMapView.setDrawOverlayWhenZooming(true);
// 初始化搜索模块,注册事件监听
mSearch = new MKSearch();
mSearch.init(mBMapMan, new MKSearchListener(){ public void onGetPoiResult(MKPoiResult res, int type, int error) {
// 错误号可参考MKEvent中的定义
if (error != 0 || res == null) {
Toast.makeText(SetAddress.this, "抱歉,未找到结果", Toast.LENGTH_LONG).show();
return;
} // 将地图移动到第一个POI中心点
if (res.getCurrentNumPois() > 0) {
// 将poi结果显示到地图上
PoiOverlay poiOverlay = new PoiOverlay(SetAddress.this, mMapView);
poiOverlay.setData(res.getAllPoi());
mMapView.getOverlays().clear();
mMapView.getOverlays().add(poiOverlay);
mMapView.invalidate();
mMapView.getController().animateTo(res.getPoi(0).pt);
} else if (res.getCityListNum() > 0) {
mSearch.poiSearchInCity(res.getCityListInfo(0).city,address.getText().toString());
String strInfo = "在";
for (int i = 0; i < res.getCityListNum(); i++) {
strInfo += res.getCityListInfo(i).city;
strInfo += ",";
}
strInfo += "找到结果";
Toast.makeText(SetAddress.this, strInfo, Toast.LENGTH_LONG).show();
}
}
public void onGetDrivingRouteResult(MKDrivingRouteResult res,
int error) {
}
public void onGetTransitRouteResult(MKTransitRouteResult res,
int error) {
}
public void onGetWalkingRouteResult(MKWalkingRouteResult res,
int error) {
}
public void onGetAddrResult(MKAddrInfo res, int error) {
}
public void onGetBusDetailResult(MKBusLineResult result, int iError) {
}
public void onGetSuggestionResult(MKSuggestionResult res, int arg1) {
// TODO Auto-generated method stub
if (arg1 != 0 || res == null) {
Toast.makeText(SetAddress.this, "抱歉,未找到结果", Toast.LENGTH_LONG).show();
return;
}
int nSize = res.getSuggestionNum();
mStrSuggestions = new String[nSize];
for (int i = 0; i < nSize; i++) {
mStrSuggestions[i] = res.getSuggestion(i).city + res.getSuggestion(i).key;
}
// ArrayAdapter<String> suggestionString = new ArrayAdapter<String>(.this, android.R.layout.simple_list_item_1,mStrSuggestions);
// mSuggestionList.setAdapter(suggestionString);
Toast.makeText(SetAddress.this, "suggestion callback", Toast.LENGTH_LONG).show(); }
public void onGetRGCShareUrlResult(String arg0, int arg1) {
// TODO Auto-generated method stub
}
});
}