最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android實(shí)現(xiàn)百度地圖兩點(diǎn)畫弧線

 更新時間:2019年01月12日 10:32:55   作者:miskss  
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)百度地圖兩點(diǎn)畫弧線,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Android實(shí)現(xiàn)百度地圖兩點(diǎn)畫弧線的具體代碼,供大家參考,具體內(nèi)容如下

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
 * 通過兩點(diǎn)來繪制弧線
 * @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 起點(diǎn)
 * @param end 終點(diǎn)
 * @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文件中計(jì)算第三個點(diǎn)的方式
 * <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 中間點(diǎn)的經(jīng)緯度
 */
 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);
  }
  }
 }
 if (lat2 == lat1) {
  t = 0;
  h = lng1 - lng2;
 } else {
  if (lng2 == lng1) {
  t = Math.PI / 2;
  h = lat1 - lat2;
  } else {
  t = Math.atan((lat2 - lat1) / (lng2 - lng1));
  h = (lat2 - lat1) / Math.sin(t);
  }
 }
 t2 = (t + (Math.PI / 5));
 h2 = h / 2;
 double lng3 = h2 * Math.cos(t2) + lng1;
 double lat3 = h2 * Math.sin(t2) + lat1;
 return new LatLng(lat3,lng3);
 }


 public LatLng getStart() {
 return start;
 }

 public void setStart(LatLng start) {
 this.start = start;
 }

 public LatLng getEnd() {
 return end;
 }

 public void setEnd(LatLng end) {
 this.end = end;
 }

 public int getColor() {
 return color;
 }

 public void setColor(int color) {
 this.color = color;
 }

 public int getArcWidth() {
 return arcWidth;
 }

 public void setArcWidth(int arcWidth) {
 this.arcWidth = arcWidth;
 }
}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

乐昌市| 五河县| 洪江市| 余姚市| 临西县| 阿拉善右旗| 太湖县| 巴彦淖尔市| 伊通| 江北区| 渭源县| 夏河县| 高平市| 瑞昌市| 尉氏县| 临邑县| 高州市| 商丘市| 新绛县| 左贡县| 肇州县| 健康| 西和县| 威远县| 开平市| 松滋市| 铁岭市| 贡觉县| 沅陵县| 威宁| 比如县| 铜山县| 临汾市| 江孜县| 汝州市| 玛多县| 桐庐县| 汕头市| 敦煌市| 肥城市| 宜川县|