### 简单做了一个百度SDK城市检索,并展示自绘的圆环,机器人图片
### 首先导入sdk中的类 OverlayManager, PoiOverlay
### main布局
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="搜索" android:onClick="btn" /> <com.baidu.mapapi.map.MapView android:id="@+id/bmapView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:clickable="true" />
### MainActivity
public class MainActivity extends AppCompatActivity { MapView mMapView = null; private BaiduMap mBaiduMap; private PoiSearch poiSearch; private EditText city, keyword; private TextView poiname, idString, poiadd; private PoiCitySearchOption poiCitySearchOption; private Button btn; private OnGetPoiSearchResultListener poiListener; LatLng center = new LatLng(39.92235, 116.380338); int radius = 500; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //在使用SDK各组件之前初始化context信息,传入ApplicationContext //注意该方法要再setContentView方法之前实现 SDKInitializer.initialize(getApplicationContext()); setContentView(R.layout.activity_main); //获取地图控件引用 mMapView = (MapView) findViewById(R.id.bmapView); mBaiduMap = mMapView.getMap(); //普通地图 mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL); //创建POI检索实例 poiSearch = PoiSearch.newInstance(); //创建POI检索监听者 poiListener = new OnGetPoiSearchResultListener() { public void onGetPoiResult(PoiResult result) { // 获取POI检索结果 if (result == null || result.error == SearchResult.ERRORNO.RESULT_NOT_FOUND) { return; } if (result.error == SearchResult.ERRORNO.NO_ERROR) { mBaiduMap.clear(); // 创建PoiOverlay PoiOverlay overlay = new PoiOverlay(mBaiduMap); // 设置overlay可以处理标注点击事件 mBaiduMap.setOnMarkerClickListener(overlay); // 设置PoiOverlay数据 overlay.setData(result); // 添加PoiOverlay到地图中 overlay.addToMap(); overlay.zoomToSpan(); showNearbyArea(center, radius); return; } } public void onGetPoiDetailResult(PoiDetailResult result) { //获取Place详情页检索结果 } @Override public void onGetPoiIndoorResult(PoiIndoorResult poiIndoorResult) { } }; } public void btn(View view) { //设置POI检索监听者 poiSearch.setOnGetPoiSearchResultListener(poiListener); //发起检索请求 poiSearch.searchInCity((new PoiCitySearchOption()) .city("北京") .keyword("长途汽车站") .pageNum(10)); } public void showNearbyArea(LatLng center, int radius) { BitmapDescriptor centerBitmap = BitmapDescriptorFactory .fromResource(R.mipmap.ic_launcher); MarkerOptions ooMarker = new MarkerOptions().position(center).icon( centerBitmap); mBaiduMap.addOverlay(ooMarker); OverlayOptions ooCircle = new CircleOptions().fillColor(0xCCCCCC00) .center(center).stroke(new Stroke(5, 0xFFFF00FF)) .radius(radius); mBaiduMap.addOverlay(ooCircle); } }