android高德地图marker图标,高德地图自定义Marker显示文字
方法一:
调用:
Marker localMarker=mAMap.addMarker(new MarkerOptions()
.position(localLatLng)
//.icon(BitmapDescriptorFactory.fromBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.map_location_icon))));
/*.icon(BitmapDescriptorFactory.
fromView(getMyView(pm.getPm()+""))));*/
.icon(BitmapDescriptorFactory.fromBitmap(getMyBitmap(pm.getPm()+""))));
localMarker.setObject(pm);
getMyBitmap方法:
protected Bitmap getMyBitmap(String pm_val) {
Bitmap bitmap = BitmapDescriptorFactory.fromResource(
R.drawable.map_location_icon).getBitmap();
bitmap = Bitmap.createBitmap(bitmap, 0 ,0, bitmap.getWidth(),
bitmap.getHeight());
Canvas canvas = new Canvas(bitmap);
TextPaint textPaint = new TextPaint();
textPaint.setAntiAlias(true);
textPaint.setTextSize(22f);
textPaint.setColor(getResources().getColor(R.color.blue));
canvas.drawText(pm_val, 17, 35 ,textPaint);// 设置bitmap上面的文字位置
return bitmap;
}
方法二:
布局文件:
mymarker.xml
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/map_location_icon"
android:scaleType="centerCrop"/>
android:id="@+id/marker_tv_val"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10px"
android:layout_marginTop="7px"
android:textColor="@android:color/black"
/>
2调用:
Marker localMarker=mAMap.addMarker(new MarkerOptions()
.position(localLatLng)
//.icon(BitmapDescriptorFactory.fromBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.map_location_icon))));
/*.icon(BitmapDescriptorFactory.
fromView(getMyView(pm.getPm()+""))));*/
.icon(BitmapDescriptorFactory.fromBitmap(getMyBitmap(pm.getPm()+""))));
localMarker.setObject(pm);
3:getMyView方法
protected View getMyView(String pm_val) {
View view=getLayoutInflater().inflate(R.layout.mymarker, null);
TextView tv_val=(TextView) view.findViewById(R.id.marker_tv_val);
tv_val.setText(pm_val);
return view;
}
第一种方法比较简洁一点
android高德地图marker图标,高德地图自定义Marker显示文字相关推荐
- 百度地图添加自定义图标标注以及自定义动画效果
百度地图添加自定义图标标注以及自定义动画效果 1.添加自定义图标标注 2.添加自定义动画效果 2.1.标注对象marker的构成 2.2.自定义动画效果实现过程 2.3.最终实现效果 上次写的是添加自 ...
- 高德地图placesearch 搜索结果生成自定义marker
业务需求: 高德地图,输入关键词输入提示(autocomplete), 按照选择的关键词执行地点搜索placesearch在地图上生成标记点marker, 点击标记点弹出自定义信息窗口infowind ...
- 修改Android设备型号、版本号、去掉自定义版本显示
1.修改型号 源码位置 build/tools/buildinfo.sh echo "ro.product.model="MTK6737_64_bsp"" ec ...
- echarts地图设置legend_echarts中关于自定义legend图例文字
formatter有两种形式: - 模板 - 回调函数 模板 使用字符串模板,模板变量为图例名称 {name} formatter: 'Legend {name}' 回调函数 formatter: f ...
- Eclipse工具栏上android的机器人小图标和adt图片的显示
这个在ecplise的工具栏上 Windows ---Perspective---open Perspective ---other, 里面就有了 手机像素不好,勉强能看清
- 百度地图添加文本标注显示文字
一.业务场景 通过百度地图API的 label 添加文本覆盖物,用于显示 marker点位的描述信息.并控制 label 的显示,鼠标移入点位的时候显示文字,不移入点位的时候不显示文字.去掉背景颜色框 ...
- matplotlib画图自定义marker
文章目录 matplotlib画图自定义marker marker的特点 通过插入图片实现自定义marker 通过Path实现自定义marker matplotlib画图自定义marker 在matp ...
- android高德地图自定义带数字marker图标,自定义图标-点标记-示例中心-JS API 示例 | 高德地图API...
图标点标记 html,body,#container{ height:100%; width:100%; } .amap-icon img{ width: 25px; height: 34px; } ...
- android mapview 自定义地图标注,关于Android集成高德地图的那些事儿...地图标注Marker 、Poi 搜索...
上一篇博客介绍了地图的显示,不要太简单了, 我们要实现的效果当然不仅仅是显示地图这么废了, 现在地图是有了 , 怎么在地图上添加一个标注呢? 添加一个圆形?又或者是我想在地图上添加个自定义的View, ...
最新文章
- 2021年春季学期-信号与系统-第十二次作业参考答案-第一小题
- 凝思系统分辨率怎么看_机械液压系统的泄漏怎么办,液压系统基本知识,看完你就懂了...
- 本地Yum生成数据库及常用命令
- linux 文件编码格式转换
- 【活动推荐】北京泛娱乐行业技术沙龙——新技术助力内容产业破局之道
- WPF企业内训全程实录(中)
- ABB 机器人 IRBP系列转台的一段代码注释
- Flask笔记-静态资源和链接的管理
- 为什么Visual Studio的安装目录下有名为1033或2052的文件夹?
- 怎么判断有用户在远程连接目标电脑_你的电脑是肉鸡吗?
- 数据库中查找哪些表中包含指定字段
- PHP使用redis防止大并发下二次写入
- GC.Collect
- LA4487 加权并查集
- background详解
- 范莎学院 计算机,申请范莎学院
- 洪水攻击程序c语言,洪水攻击原理及代码实现全攻略(附源代码)
- 醉后不知天在水 满船清梦压星河。—第二十一天
- sublime运行python只显示时间_sublime3-python 编译运行不显示内容
- 必读的AI和深度学习博客