mBaiduMap.setOnMapClickListener(new BaiduMap.OnMapClickListener() {
@ Override
public void onMapClick(LatLng latLng) {
}
@ Override
public void onMapPoiClick(MapPoi mapPoi) {
String name = mapPoi.getName();
LatLng latLng = mapPoi.getPosition();
final String s = "geo:" + latLng.latitude + "," + latLng.longitude;
AlertDialog.Builder builder = new AlertDialog.Builder(HistoryLocus.this);
builder.setIcon(android.R.drawable.ic_dialog_map);
builder.setTitle(name);
builder.setMessage(s);
builder.setPositiveButton("分享", new DialogInterface.OnClickListener() {
@ Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, s);
intent.setType("text/plain");
startActivity(Intent.createChooser(intent, "分享到"));
}
});
builder.setNegativeButton("取消", null);
builder.create().show();
}
});
mBaiduMap.setOnMapLongClickListener(new BaiduMap.OnMapLongClickListener() {
public void onMapLongClick(final LatLng latLng) {
final String s = "geo:" + latLng.latitude + "," + latLng.longitude;
AlertDialog.Builder builder = new AlertDialog.Builder(HistoryLocus.this);
builder.setIcon(android.R.drawable.ic_dialog_map);
builder.setTitle("地点");
builder.setMessage(s);
builder.setPositiveButton("分享", new DialogInterface.OnClickListener() {
@ Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, s);
intent.setType("text/plain");
startActivity(Intent.createChooser(intent, "分享到"));
}
});
builder.setNegativeButton("取消", null);
builder.create().show();
}
});
项目地址:GitLink | 确实开源