我顯示此鏈接,但答案只是顯示氣球。帶有邊框的圖像覆蓋使用android
Picture with a border as a map overlay
但我發現就像顯示影像邊框....篩選。
如果任何人有任何想法如何做到這一點,請幫助我。
我完成了在地圖上顯示3-5個圖像。但現在我只想顯示帶有邊框的圖像。
在此先感謝。
我顯示此鏈接,但答案只是顯示氣球。帶有邊框的圖像覆蓋使用android
Picture with a border as a map overlay
但我發現就像顯示影像邊框....篩選。
如果任何人有任何想法如何做到這一點,請幫助我。
我完成了在地圖上顯示3-5個圖像。但現在我只想顯示帶有邊框的圖像。
在此先感謝。
這裏是一些代碼,打圈:
private class ProximityOverlay extends Overlay {
public void draw(Canvas canvas, MapView mapview, boolean b) {
// draw some stuff in here, like
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setStrokeWidth(2.0f);
double latitude = location.getLatitude();
double longitude = location.getLongitude();
Projection projection = mapView.getProjection();
GeoPoint leftGeo = new GeoPoint((int) (latitude * 1e6),
(int) (longitude * 1e6));
Point left = new Point();
projection.toPixels(leftGeo, left);
paint.setColor(Color.parseColor("#00CCFF"));
paint.setStyle(Style.FILL);
canvas.drawCircle(left.x, left.y, 9, paint);
paint.setColor(Color.parseColor("#003399"));
paint.setStyle(Style.STROKE);
canvas.drawCircle(left.x, left.y, 10, paint);
}
你可以修改它畫一個黑色矩形:
canvas.drawRect(left, top, right, bottom, paint);
你需要創建一個這樣
圖像,這是9修補圖像。
現在您需要創建自定義佈局來處理顯示這個自定義佈局文件氣球
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="35dip"
android:paddingLeft="10dip"
android:id="@+id/balloon_main_layout"
android:background="@drawable/balloon_overlay_bg_selector"
android:paddingTop="0dip"
android:paddingRight="0dip">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/your_default_image"
android:id="@+id/img_button"
android:paddingLeft="10dip"
android:paddingBottom="10dip"
android:paddingRight="8dip"
android:paddingTop="8dip"></ImageView>
</LinearLayout>
現在
你可以創建這種類型的圖像,並設置爲佈局背景,在ImageView的顯示不同圖像按您的要求
創建一個類BalloonItemizedOverlay在here
建議,當你想展示重疊(例如我有這樣的創建)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="5dip"
android:paddingLeft="5dip"
android:id="@+id/balloon_main_layout"
android:background="@drawable/popupbg"
android:paddingTop="0dip"
>
<ImageView android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/diseaseImg"
android:padding="5dp"
android:layout_gravity="center_vertical"
></ImageView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1"
android:paddingTop="10dip"
android:paddingRight="30dip"
android:id="@+id/balloon_inner_layout">
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/balloon_item_title"
android:text="balloon_item_title"
android:layout_marginLeft="2dp"
android:textSize="14dip"
android:paddingBottom="5dp"
android:textColor="#FF000000"></TextView>
</LinearLayout>
<ImageView android:layout_width="30dp"
android:layout_height="30dp"
android:src="@android:drawable/ic_menu_close_clear_cancel"
android:id="@+id/close_img_button"
android:layout_gravity="right"
android:paddingLeft="10dip"
android:paddingBottom="10dip"
android:paddingRight="8dip"
android:paddingTop="2dip"></ImageView>
</LinearLayout>
,也可以創建類BalloonOverlayView如創建XML下面
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.ImageView.ScaleType;
import com.google.android.maps.OverlayItem;
import com.healthcarealert.R;
public class BalloonOverlayView extends FrameLayout {
private LinearLayout layout;
private TextView title;
private TextView snippet;
private ImageView diseaseImg;
public static boolean isPopupClicked = false;
private Context con = null;
/**
* Create a new BalloonOverlayView.
*
* @param context - The activity context.
* @param balloonBottomOffset - The bottom padding (in pixels) to be applied
* when rendering this view.
*/
public BalloonOverlayView(Context context, int balloonBottomOffset) {
super(context);
this.con =context;
setPadding(10, 0, 10, balloonBottomOffset);
layout = new LinearLayout(context);
layout.setVisibility(VISIBLE);
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflater.inflate(R.layout.balloon_map_overlay, layout);
title = (TextView) v.findViewById(R.id.balloon_item_title);
// snippet = (TextView) v.findViewById(R.id.balloon_item_snippet);
diseaseImg = (ImageView)v.findViewById(R.id.diseaseImg);
ImageView close = (ImageView) v.findViewById(R.id.close_img_button);
close.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
layout.setVisibility(GONE);
}
});
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.gravity = Gravity.NO_GRAVITY;
addView(layout, params);
}
/**
* Sets the view data from a given overlay item.
*
* @param item - The overlay item containing the relevant view data
* (title and snippet).
*/
public void setData(OverlayItem item) {
layout.setVisibility(VISIBLE);
if (item.getTitle() != null) {
title.setVisibility(VISIBLE);
title.setText(item.getTitle());
} else {
title.setVisibility(GONE);
}
/*if (item.getSnippet() != null) {
snippet.setVisibility(VISIBLE);
snippet.setText(item.getSnippet());
} else {
snippet.setVisibility(GONE);
}*/
}
public void setImage(String item) {
layout.setVisibility(VISIBLE);
if (item != null) {
diseaseImg.setVisibility(VISIBLE);
ImageLoader imageLoader = new ImageLoader(this.con);;
diseaseImg.setTag("http://healthcarealert.com/healthcaretest/" + item);
diseaseImg.setScaleType(ScaleType.FIT_XY);
imageLoader.DisplayImage("http://healthcarealert.com/healthcaretest/" + item,
HotSpotsMapActivity.activity, diseaseImg);
} else {
diseaseImg.setVisibility(GONE);
}
}
}
具有這種類梅索德setImage(字符串項)
如果字符串包含圖像的URL
調用此方法HelloItemised疊加中的onTap梅索德與圖像URL路徑