Android 高德地图添加线段纹理
来源:互联网 发布:51内核单片机 编辑:程序博客网 时间:2024/03/29 16:00
共享单车轨迹界面如:小黄车和摩拜单车界面布局采用的是高德地图,并且每个轨迹线段都是有对应的地图纹理
首先,我们在高德地图开发环境下进行地图线段纹理开发需要明确几个前提:
- 线段添加纹理根据官方文档是在PolylienOptions 类中进行设置
- PolylienOptions 类所在的包是:com.amap.api.maps.model.PolylineOptions;
- 对于com.amap.api.maps2d.AMap所对应的AMap中也有一个PolylienOptions 类,但是该类不能进行纹理的设置
官方文档说明如下:
首先,你需要你自己的纹理图。如下三个纹理图片
代码开发:
将纹理图片放置到Asset文件目录下面
工具类代码如下:
/** * Created by adminZPH on 2017/4/14. * 设置线条中的纹理的方法 * @return PolylineOptions * */ public static PolylineOptions GetPolylineOptions(){ //添加纹理图片 List<BitmapDescriptor> textureList = new ArrayList<BitmapDescriptor>(); BitmapDescriptor mRedTexture = BitmapDescriptorFactory .fromAsset("icon_road_red_arrow.png"); BitmapDescriptor mBlueTexture = BitmapDescriptorFactory .fromAsset("icon_road_blue_arrow.png"); BitmapDescriptor mGreenTexture = BitmapDescriptorFactory .fromAsset("icon_road_green_arrow.png"); textureList.add(mRedTexture); textureList.add(mBlueTexture); textureList.add(mGreenTexture); // 添加纹理图片对应的顺序 List<Integer> textureIndexs = new ArrayList<Integer>(); textureIndexs.add(0); textureIndexs.add(1); textureIndexs.add(2); PolylineOptions polylienOptions=new PolylineOptions(); polylienOptions.setCustomTextureList(textureList); polylienOptions.setCustomTextureIndex(textureIndexs); polylienOptions.setUseTexture(true); polylienOptions.width(7.0f); return polylienOptions; }
上面方法用来返回一个polylienOptions,如果你有N个经纬度点的话,需要在地图上两两连线添加纹理显示,就可直接使用
比如:
for (int i =0; i < a.size() - 1; ++i) { amap.addPolyline(GetPolylineOptions()).add( new LatLng(a.get(i).getLatLonPoint().getLatitude(), a.get(i).getLatLonPoint().getLongitude()), new LatLng(a.get(i + 1).getLatLonPoint().getLatitude(), a.get(i + 1).getLatLonPoint().getLongitude()) ); }
通过上述就可以实现,具体业务逻辑具体编写。
这片海 2017.04.14 13:06
0 0
- Android 高德地图添加线段纹理
- (Android 地图开发) 高德地图添加覆盖物
- (android地图开发) 高德地图添加自定义菜单栏
- (android 地图开发) 高德地图添加浮动按钮
- (android地图开发) 高德地图添加抽屉栏效果
- 百度地图添加纹理折线
- Android-高德地图
- android 高德地图
- 高德地图绘制多边形和线段
- 高德地图02---高德地图添加覆盖物
- Android OpenGL添加纹理
- Android高德地图开发 地图事件
- Android高德地图自定义地图指南针
- 高德地图添加手势不响应
- 高德地图-添加自定义图标
- 高德地图添加Marker点标记
- 高德地图之添加遮盖物
- 高德地图Key添加之SHA1
- 读书学习心得
- cocoapods出现的问题
- oracle 存储过程、存储函数、程序包
- jquery.form.js提交form表单 上传文件
- 打擂台排序与冒泡排序(未完)
- Android 高德地图添加线段纹理
- poj2386.cpp
- 富文本编辑器kinduditor的使用
- 观察者模式--农民的故事
- MFC笔记:实现左键拖拽
- 遇见大数据可视化:基础研究
- Ubuntu 16.04安装Cuda8.0
- 一篇文章带你制作 canvas 小游戏 (2)
- C#创建Windows Service(Windows 服务)基础教程