百度地图添加带有图案的多边形区域
2017-07-13 10:05
190 查看
日常的工作中绘制多边形区域可以设置单色矩形区域,但是特殊需求下,需要绘制指定图案的边框,下面就简单实现下
多种颜色矩形
/**
* 绘制围栏
*/
private void drawBitmapDescriptor(List<LatLng> points) {
BitmapDescriptor custom1 = BitmapDescriptorFactory
.fromResource(R.mipmap.icon_road_red_arrow);
BitmapDescriptor custom2 = BitmapDescriptorFactory
.fromResource(R.mipmap.icon_road_green_arrow);
BitmapDescriptor custom3 = BitmapDescriptorFactory
.fromResource(R.mipmap.icon_road_blue_arrow);
//构造纹理队列
List<BitmapDescriptor> customList = new ArrayList<>();
customList.add(custom1);
customList.add(custom2);
customList.add(custom3);
List<Integer> index = new ArrayList<>();
index.add(0);
index.add(1);
index.add(2);
//构造对象
OverlayOptions ooPolyline = new PolylineOptions().width(25).dottedLine(true).color(0xAAFF0000).points(points)
.customTextureList(customList).textureIndex(index);
//添加到地图
mBaiduMap.addOverlay(ooPolyline);
}单色多边形
/**
* 绘制围栏
*/
private void drawBitmapDescriptor(List<LatLng> points) {
BitmapDescriptor custom1 = BitmapDescriptorFactory
.fromResource(R.mipmap.icon_road_red_arrow1);
//构造纹理队列
List<BitmapDescriptor> customList = new ArrayList<>();
customList.add(custom1);
List<Integer> index = new ArrayList<>();
index.add(0);
//构造对象
OverlayOptions ooPolyline = new PolylineOptions().width(25).dottedLine(true).color(0xAAFF0000).points(points)
.customTextureList(customList).textureIndex(index);
//添加到地图
mBaiduMap.addOverlay(ooPolyline);
}
可以看出其实单色和多色区别在于customList中的图片数量,想要更绚丽的效果,大家自行发挥。
其中width用于设置边框的宽度,dotterLine用于设置两个图片拼接中间是否有分割点,points是传入的经纬度集合,customTextureList是边框样式
textureIndex是指添加的边框集合中的索引,如果有多张图的话,index索引的变化会改变边框矩形样式,如果custonTextureList中只有一个样式的话,则index中添加几次都只显示一种样式。
多种颜色矩形
/**
* 绘制围栏
*/
private void drawBitmapDescriptor(List<LatLng> points) {
BitmapDescriptor custom1 = BitmapDescriptorFactory
.fromResource(R.mipmap.icon_road_red_arrow);
BitmapDescriptor custom2 = BitmapDescriptorFactory
.fromResource(R.mipmap.icon_road_green_arrow);
BitmapDescriptor custom3 = BitmapDescriptorFactory
.fromResource(R.mipmap.icon_road_blue_arrow);
//构造纹理队列
List<BitmapDescriptor> customList = new ArrayList<>();
customList.add(custom1);
customList.add(custom2);
customList.add(custom3);
List<Integer> index = new ArrayList<>();
index.add(0);
index.add(1);
index.add(2);
//构造对象
OverlayOptions ooPolyline = new PolylineOptions().width(25).dottedLine(true).color(0xAAFF0000).points(points)
.customTextureList(customList).textureIndex(index);
//添加到地图
mBaiduMap.addOverlay(ooPolyline);
}单色多边形
/**
* 绘制围栏
*/
private void drawBitmapDescriptor(List<LatLng> points) {
BitmapDescriptor custom1 = BitmapDescriptorFactory
.fromResource(R.mipmap.icon_road_red_arrow1);
//构造纹理队列
List<BitmapDescriptor> customList = new ArrayList<>();
customList.add(custom1);
List<Integer> index = new ArrayList<>();
index.add(0);
//构造对象
OverlayOptions ooPolyline = new PolylineOptions().width(25).dottedLine(true).color(0xAAFF0000).points(points)
.customTextureList(customList).textureIndex(index);
//添加到地图
mBaiduMap.addOverlay(ooPolyline);
}
可以看出其实单色和多色区别在于customList中的图片数量,想要更绚丽的效果,大家自行发挥。
其中width用于设置边框的宽度,dotterLine用于设置两个图片拼接中间是否有分割点,points是传入的经纬度集合,customTextureList是边框样式
textureIndex是指添加的边框集合中的索引,如果有多张图的话,index索引的变化会改变边框矩形样式,如果custonTextureList中只有一个样式的话,则index中添加几次都只显示一种样式。
相关文章推荐
- 百度地图:普通覆盖物,以及多边形覆盖物,及他们的描述信息的添加,修改,删除,查看功能,还有多边形根据名称查询功能;
- 百度地图 判断一个标注点是否在多边形区域里
- 百度地图笔记_多边形覆盖物区域加标签
- 百度地图绘制多边形图层内添加文字
- 百度地图 判断一个标注点是否在多边形区域里
- JS - 百度地图 判断一个标注点是否在多边形区域里
- 百度地图 判断一个标注点是否在多边形区域里
- 百度地图 判断一个标注点是否在多边形区域里
- Java类判断百度地图上某点是否在多边形区域内
- 多边形区域填充算法--扫描线填充算法(有序边表法)
- collectionviewcell 添加删除按钮 响应区域的问题
- html在百度地图上添加一个悬浮div
- iOS学习笔记: 使用CAShapeLayer创建带有空心区域的遮罩层
- c# 判断点是否在区域内 点在区域内 在多边形内 判断
- 添加到网站上的百度地图,标注图标不显示
- 百度地图添加方向传感器
- 添加区域视图 找到多个与名为“home”的控制器匹配的类型
- 百度地图 循环加载marker并添加多个信息窗口,解决只显示最后一个窗口信息的问题
- 在MVC中添加区域的真正正确的方法!
- Java 判断 一个点是不是在一个多边形围起来的区域内