예제 #1
0
 @Override
 public boolean onMarkerClick(Marker marker) {
   final BranchInfo item = (BranchInfo) marker.getExtraInfo().getSerializable("info");
   Button button = new Button(getApplicationContext());
   button.setText(item.getStation_name() + ">>");
   button.setOnClickListener(
       new View.OnClickListener() {
         public void onClick(View v) {
           showPopup(item);
         }
       });
   LatLng ll = marker.getPosition();
   mInfoWindow = new InfoWindow(button, ll, -47);
   mBaiduMap.showInfoWindow(mInfoWindow);
   return true;
 }
예제 #2
0
 void loadMarker() {
   for (BranchInfo item : mData) {
     if (item.getLat() == 0 || item.getLng() == 0) continue;
     LatLng latLng = new LatLng(item.getLat(), item.getLng());
     Marker marker =
         (Marker)
             mBaiduMap.addOverlay(
                 new MarkerOptions()
                     .position(latLng)
                     .icon(BitmapDescriptorFactory.fromResource(R.mipmap.ic_map_marker)));
     Bundle bundle = new Bundle();
     bundle.putSerializable("info", item);
     marker.setExtraInfo(bundle);
     // 将地图移到到最后一个经纬度位置
     MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(latLng);
     mBaiduMap.setMapStatus(u);
   }
   mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newLatLng(mMyLocation));
 }