美文网首页
Android百度地图API只能显示一个infowindow的完

Android百度地图API只能显示一个infowindow的完

作者: 流沙3333 | 来源:发表于2017-07-19 14:41 被阅读423次

参考:  http://blog.csdn.net/u012534831/article/details/52636741

private Bitmap drawbitmap() {

//TODO Auto-generated method stub

Bitmap photo = BitmapFactory.decodeResource(ActivityHelper.last().getResources(),R.drawable.popup);

intwidth = photo.getWidth();

inthight = photo.getHeight();

Bitmap newb = Bitmap.createBitmap(width,hight,Bitmap.Config.ARGB_8888);

Canvas canvas =newCanvas(newb);// 初始化和方框一样大小的位图

Paint photoPaint =newPaint();// 建立画笔

canvas.drawBitmap(photo,0,0,photoPaint);

canvas.save(Canvas.ALL_SAVE_FLAG);

canvas.restore();

returnnewb;

}

private Bitmap drawtext(Bitmap bitmap3,String info) {

//TODO Auto-generated method stub

TextPaint textPaint =newTextPaint(Paint.ANTI_ALIAS_FLAG| Paint.DEV_KERN_TEXT_FLAG);//设置画笔

textPaint.setTextSize(UnitUtils.sp2px(ActivityHelper.last().getBaseContext(),12));//字体大小

textPaint.setTextAlign(Paint.Align.CENTER);

textPaint.setTypeface(Typeface.DEFAULT_BOLD);//采用默认的宽度

textPaint.setColor(Color.parseColor("#FD571B"));//采用的颜色

intwidth = (int)textPaint.measureText(info) +20;

inthight = UnitUtils.dip2px(ActivityHelper.last().getBaseContext(),20);

Bitmap btm= Bitmap.createBitmap(width,hight,Bitmap.Config.ARGB_8888);//建立一个空的BItMap

Canvas canvas =newCanvas(btm);

Paint photoPaint =newPaint();//建立画笔

photoPaint.setDither(true);//获取跟清晰的图像采样

photoPaint.setFilterBitmap(true);//过滤一些

Rect src =newRect(0,0,bitmap3.getWidth(),bitmap3.getHeight());//创建一个指定的新矩形的坐标

Rect dst =newRect(0,0,width,hight);//创建一个指定的新矩形的坐标

canvas.drawBitmap(bitmap3,src,dst,photoPaint);//将photo 缩放或则扩大到 dst使用的填充区photoPaint

canvas.drawText(info,width/2,hight/2+ UnitUtils.dip2px(ActivityHelper.last().getBaseContext(),3),textPaint);//绘制上去字,中间参数为坐标点

canvas.save(Canvas.ALL_SAVE_FLAG);//保存

canvas.restore();

returnbtm;

}

Bitmap bitmap = drawtext(drawbitmap(),item.getName());//  drawbitmap();//

LatLng pt2 =newLatLng(item.getLatitude(),item.getLongitude());

BitmapDescriptor des = BitmapDescriptorFactory.fromBitmap(bitmap);

OverlayOptions option =newMarkerOptions().position(pt2).icon(des).zIndex(9);

mBaiduMap.addOverlay(option);

相关文章

网友评论

      本文标题:Android百度地图API只能显示一个infowindow的完

      本文链接:https://www.haomeiwen.com/subject/cmylkxtx.html