我想在android中的map v2中制作自定义信息窗口适配器,如下所示.

我已经看到下面的链接,但没有得到更多.
下面是我的内容布局文件.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<ImageView
android:id="@+id/infocontent_iv_image"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_alignParentTop="true"
/>
<RelativeLayout
android:id="@+id/infocontent_rl_middle"
android:layout_below="@id/infocontent_iv_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
>
</RelativeLayout>
<TextView
android:id="@+id/infocontent_tv_name"
android:layout_below="@id/infocontent_rl_middle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:layout_margin="5dp"
/>
<TextView
android:id="@+id/infocontent_tv_type"
android:layout_below="@id/infocontent_tv_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#CCCCCC"
android:layout_margin="5dp"
/>
<TextView
android:id="@+id/infocontent_tv_desc"
android:layout_below="@id/infocontent_tv_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
/>
<TextView
android:id="@+id/infocontent_tv_addr"
android:layout_below="@id/infocontent_tv_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
所以任何人都可以帮助我如何将数据设置为infowindow适配器中的所有视图?
使用Google Map API V3时,我可以通过以下方式添加自定义属性:
var marker = new google.maps.Marker({
position: userLocation,
map: myGoogleMap,
animation: google.maps.Animation.DROP,
icon: avatar,
title: userName,
customProperty1: bla,
customProperty2: bla,
customProperty3: bla,
...
Run Code Online (Sandbox Code Playgroud)
});
我想知道我是否可以为API V2 Android做同样的事情,我想这样做的原因是每个标记的每个信息窗口都需要知道该标记的一些信息.而我正在努力实现以下render功能:
private void render(Marker marker, View view) {
int badge = R.drawable.android_face;
if (marker.customProperty)
//here I need to know this property to decide which image to use
badge = R.drawable.bla;
((ImageView) view.findViewById(R.id.badge))
.setImageResource(badge);
}
Run Code Online (Sandbox Code Playgroud) 当我在Google的Google地图Android应用程序中找到最近的餐馆时,餐厅名称默认显示在标记图标附近.(请参阅Google图片).
但在我的应用程序中,当我搜索最近的餐馆时,我需要这样做,我只能显示标记图标.(参考我的应用图片).
谷歌图片:
我的申请图片:
部分解决方案: 在这里我找到了部分解决方案,我们通过使用画布绘制文本来实现.我使用下面的代码在这里和这里引用这些链接但画布绘制切割我的文本.参考附图图像TextDrawn图像
Marker myLocMarker = map.addMarker(new MarkerOptions()
.position(myLocation)
.icon(BitmapDescriptorFactory.fromBitmap(writeTextOnDrawable(R.drawable.bluebox, "your text goes here"))));
private Bitmap writeTextOnDrawable(int drawableId, String text) {
Bitmap bm = BitmapFactory.decodeResource(context.getResources(), drawableId)
.copy(Bitmap.Config.ARGB_8888, true);
Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL);
paint.setColor(Color.BLACK);
paint.setTextAlign(Paint.Align.CENTER);
paint.setLinearText(true);
paint.setAntiAlias(true);
paint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
paint.setTextSize(35);
Rect textRect = new Rect();
paint.getTextBounds(text, 0, text.length(), textRect);
Canvas canvas = new Canvas(bm);
//Calculate the positions
// int xPos = (canvas.getWidth() / 2) - 2; //-2 is for regulating the x …Run Code Online (Sandbox Code Playgroud) android google-maps android-canvas google-maps-android-api-2 google-nearby
如何使用Picasso和Google Marker Custom Icon来实现此功能?
我知道如何将Picasso用于图像,但我不知道如何在底部和边框上添加"标记图标".
Picasso.with(mContext)
.load(url)
.resize(250, 250)
.centerInside()
.into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
Marker driver_marker = mMap.addMarker(new MarkerOptions()
.position(new LatLng(Double.parseDouble(lat), Double.parseDouble(lng)))
.icon(BitmapDescriptorFactory.fromBitmap(bitmap))
.title(name)
.snippet(address)
);
@Override
public void onBitmapFailed (Drawable errorDrawable){
}
@Override
public void onPrepareLoad (Drawable placeHolderDrawable){
}
});
}
Run Code Online (Sandbox Code Playgroud)
我在onBitmapLoaded中添加了这个:
Paint paint = new Paint();
paint.setColor(Color.YELLOW);
paint.setStrokeWidth(10);
paint.setShadowLayer(5, 0, 1, Color.RED);
Canvas canvas = new Canvas(bitmap);
canvas.drawLine(0, 0, canvas.getWidth(), 0, paint);
canvas.drawLine(0, 0, 0, canvas.getHeight(), paint);
canvas.drawLine(0, canvas.getHeight(), canvas.getWidth(), canvas.getHeight(), …Run Code Online (Sandbox Code Playgroud) 我正在尝试做类似这样的事情: Android Map api v2自定义标记与ImageView 但我坚持使用图像加载器.
试:
Bitmap bmImg = imageLoader.loadImageSync(url);
Run Code Online (Sandbox Code Playgroud)
LogCat给了我
04-13 14:11:44.953: E/ImageLoader(18542): android.os.NetworkOnMainThreadException
Run Code Online (Sandbox Code Playgroud)
这是我的代码.我有一个ArrayList相机,需要所有信息(titrle,position,url等).
public void drawPicsOnMap()
{
String title = null;
String place = null;
for (int i = 0; i<camera.size(); i++)
{
Bitmap.Config conf = Bitmap.Config.ARGB_8888;
Bitmap bmp = Bitmap.createBitmap(80, 80, conf);
Canvas canvas = new Canvas(bmp);
// paint defines the text color,
// stroke width, size
Paint color = new Paint();
color.setTextSize(35);
color.setColor(Color.BLACK);
Camera cam = camera.get(i);
LatLng coord = new LatLng(cam.lat, cam.lon);
title …Run Code Online (Sandbox Code Playgroud) 我创建了一个使用谷歌地图的移动应用程序,但我似乎无法自动显示标记标题.我总是必须点击标记才能显示其标题.一旦标记标题出现在地图上,它是否有任何方法可以自动显示?我希望能够一次显示标记的标题.