没有合适的资源?快使用搜索试试~ 我知道了~
Android实现百度地图两点画弧线
0 下载量 57 浏览量
2020-08-26
10:54:40
上传
评论
收藏 33KB PDF 举报
温馨提示


试读
2页
主要为大家详细介绍了Android实现百度地图两点画弧线,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
资源推荐
资源详情
资源评论












Android实现百度地图两点画弧线实现百度地图两点画弧线
主要为大家详细介绍了Android实现百度地图两点画弧线,具有一定的参考价值,感兴趣的小伙伴们可以参考一
下
本文实例为大家分享了Android实现百度地图两点画弧线的具体代码,供大家参考,具体内容如下
import android.support.annotation.NonNull;
import com.baidu.mapapi.map.ArcOptions;
import com.baidu.mapapi.map.OverlayOptions;
import com.baidu.mapapi.model.LatLng;
/**
*
* http://lbsyun.baidu.com/index.php?title=androidsdk/guide/render-map/ploygon
* 通过两点来绘制弧线
* @author peter 2018-12-24 15:09
*/
public class ArcOverlay {
private LatLng start;
private LatLng end;
/**
* {@link com.baidu.mapapi.map.ArcOptions#color(int)}
*/
private int color;//弧线的颜色
private int arcWidth = 4;//弧线宽度
public ArcOverlay(@NonNull LatLng start, @NonNull LatLng end, int color) {
this.start = start;
this.end = end;
this.color = color;
}
/**
* 获取一个弧线Overlay
* @param start 起点
* @param end 终点
* @param color 颜色
* @param arcWidth 弧线宽度
*/
public ArcOverlay(@NonNull LatLng start, @NonNull LatLng end, int color, int arcWidth) {
this.start = start;
this.end = end;
this.color = color;
this.arcWidth = arcWidth;
}
public OverlayOptions toBmapOverlayOptions() {
return new ArcOptions()
.color(color)
.width(arcWidth)
.points(start, getMidPoint(), end);
}
/**
* 参考前端百度提供的画弧线js文件中计算第三个点的方式
* <a>http://lbsyun.baidu.com/jsdemo.htm#c1_13</a>
* <a>view-source:http://api.map.baidu.com/library/CurveLine/1.5/src/CurveLine.min.js<a/>
* @return 中间点的经纬度
*/
private LatLng getMidPoint() {
double t, t2, h,h2;
double lng1 = start.longitude;
double lng2 = end.longitude;
double lat1 = start.latitude;
double lat2 = end.latitude;
if (lng2 > lng1) {
if ((lng2 - lng1) > 180) {
if (lng1 < 0) {
lng1 = (180 + 180 + lng1);
}
}
}
if (lng1 > lng2) {
if ((lng1 - lng2) > 180) {
if (lng2 < 0) {
lng2 = (180 + 180 + lng2);
资源评论


weixin_38529436
- 粉丝: 3
- 资源: 998
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


安全验证
文档复制为VIP权益,开通VIP直接复制
