API:http://developer.baidu.com/map/android_refer/overview-summary.html
推荐文章:
http://blog.csdn.net/ynxdb2002/article/details/51786246
http://blog.csdn.net/aconghui/article/details/50958715
SDK下载:
http://lbsyun.baidu.com/sdk/download
秘钥申请:
http://developer.baidu.com/map/geosdk-android-key.htm
总结:
点聚合功能不是更新jar包,而是将下载的sdk项目BaiduMapsApiDemo里面所需要的src,xml,styles.xml整合。
附:
一:点击mark的时候,显示额外的信息。
1.添加mark:
itemsList.add(new MyItem(shop_ll,shop_type,bun));
2.设置每个mark
/**
* 每个Marker点,包含Marker点坐标,图标和额外信息
*/
public class MyItem implements ClusterItem {
private final LatLng mPosition;
private String shop_type;
private Bundle buns;
public MyItem(LatLng latLng) {
mPosition = latLng;
}
public MyItem(LatLng latLng,String shopType,Bundle bun) {
mPosition = latLng;
shop_type=shopType;
buns=bun;
}
@Override
public LatLng getPosition() {
return mPosition;
}
@Override
public Bundle <strong><span style="color:#6600CC;">getExtraInfo</span></strong>() {
return buns;
}
@Override
public BitmapDescriptor getBitmapDescriptor() {
if (shop_type.trim().equals("2")) {
return BitmapDescriptorFactory.fromResource(R.drawable.delicacies_logo);
} else if (shop_type.trim().equals("3")) {
return BitmapDescriptorFactory.fromResource(R.drawable.shopping_logo);
} else if (shop_type.trim().equals("4")) {
return BitmapDescriptorFactory.fromResource(R.drawable.hotel_logo);
} else if (shop_type.trim().equals("5")) {
return BitmapDescriptorFactory.fromResource(R.drawable.entertainment_logo);
} else if (shop_type.trim().equals("6")) {
return BitmapDescriptorFactory.fromResource(R.drawable.life_service_logo);
}else{
return BitmapDescriptorFactory .fromResource(R.drawable.icon_gcoding);
}
}
}
3.接口添加新的抽象方法:
public interface ClusterItem {
/**
* The position of this marker. This must always return the same value.
*/
LatLng getPosition();
BitmapDescriptor getBitmapDescriptor();
Bundle <strong><span style="color:#FF6666;">getExtraInfo</span></strong>();
}
4.DefaultClusterRenderer类。默认是sdk是没有添加额外信息,所以要自己加:
mRenderer.setOnClusterItemClickListener(mOnClusterItemClickListener);
/**
* Creates markerWithPosition(s) for a particular cluster, animating it if necessary.
*/
private class CreateMarkerTask {
private final Cluster<T> cluster;
private final Set<MarkerWithPosition> newMarkers;
private final LatLng animateFrom;
/**
* @param c the cluster to render.
* @param markersAdded a collection of markers to append any created markers.
* @param animateFrom the location to animate the markerWithPosition from, or null if no
* animation is required.
*/
public CreateMarkerTask(Cluster<T> c, Set<MarkerWithPosition> markersAdded, LatLng animateFrom) {
this.cluster = c;
this.newMarkers = markersAdded;
this.animateFrom = animateFrom;
}
private void perform(MarkerModifier markerModifier) {
// Don't show small clusters. Render the markers inside, instead.
if (!shouldRenderAsCluster(cluster)) {
for (T item : cluster.getItems()) {
Marker marker = mMarkerCache.get(item);
MarkerWithPosition markerWithPosition;
if (marker == null) {
MarkerOptions markerOptions = new MarkerOptions();
if (animateFrom != null) {
markerOptions.position(animateFrom);
markerOptions.icon(item.getBitmapDescriptor());
<span style="color:#FF6666;"><strong>markerOptions.extraInfo(item.getExtraInfo());</strong></span>
} else {
markerOptions.position(item.getPosition());
markerOptions.icon(item.getBitmapDescriptor());
<span style="color:#FF6666;"><strong>markerOptions.extraInfo(item.getExtraInfo());</strong></span>
}
onBeforeClusterItemRendered(item, markerOptions);
marker = mClusterManager.getMarkerCollection().addMarker(markerOptions);
markerWithPosition = new MarkerWithPosition(marker);
mMarkerCache.put(item, marker);
if (animateFrom != null) {
markerModifier.animate(markerWithPosition, animateFrom, item.getPosition());
}
} else {
markerWithPosition = new MarkerWithPosition(marker);
}
onClusterItemRendered(item, marker);
newMarkers.add(markerWithPosition);
}
return;
}
MarkerOptions markerOptions = new MarkerOptions()
.position(animateFrom == null ? cluster.getPosition() : animateFrom);
onBeforeClusterRendered(cluster, markerOptions);
Marker marker = mClusterManager.getClusterMarkerCollection().addMarker(markerOptions);
mMarkerToCluster.put(marker, cluster);
mClusterToMarker.put(cluster, marker);
MarkerWithPosition markerWithPosition = new MarkerWithPosition(marker);
if (animateFrom != null) {
markerModifier.animate(markerWithPosition, animateFrom, cluster.getPosition());
}
onClusterRendered(cluster, marker);
newMarkers.add(markerWithPosition);
}
}
API: MarkerOption com.baidu.mapapi.map.MarkerOptions