浏览器版本低!无法浏览完整内容,建议升级或更换浏览器。

文档全面上新

更科技的视觉体验,更高效的页面结构,快前往体验吧!

体验新版
第49行: 第49行:
 
                     </div>
 
                     </div>
 
                     <div class="wrap_right_nav_r">下载源码</div><!-- 安卓源码地址 -->
 
                     <div class="wrap_right_nav_r">下载源码</div><!-- 安卓源码地址 -->
                     <div class="github-url-and">//mapopen-website-wiki.bj.bcebos.com/demos/iosVideos/iOS示例中心Demo.zip</div>
+
                     <div class="github-url-and">//mapopen-website-wiki.bj.bcebos.com/demos/iosVideos/iOS示例中心Demo.zip
 +
                    </div>
 
                 </div>
 
                 </div>
 
                 <div class="wrap_table">
 
                 <div class="wrap_table">
第61行: 第62行:
 
                             <div>接口</div>
 
                             <div>接口</div>
 
                             <div>描述</div>
 
                             <div>描述</div>
                         </div>
+
                         </div><!-- 表格接口,可有多个 -->
                        <!-- 表格接口,可有多个 -->
+
 
                         <div class="table_wrap_con">
 
                         <div class="table_wrap_con">
 
                             <div class="table_wrap_w">
 
                             <div class="table_wrap_w">
第69行: 第69行:
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
                                     <div>points</div>
+
                                     <div>points(List<LatLng> points)</div>
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
 
                                     <div>设置Polyline坐标点列表</div>
 
                                     <div>设置Polyline坐标点列表</div>
 
                                 </div>
 
                                 </div>
                               
 
 
                             </div><!--  -->
 
                             </div><!--  -->
 
                             <div class="table_wrap_w">
 
                             <div class="table_wrap_w">
第81行: 第80行:
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
                                     <div>width</div>
+
                                     <div>width(int width)</div>
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
 
                                     <div>设置Polyline宽度</div>
 
                                     <div>设置Polyline宽度</div>
 
                                 </div>
 
                                 </div>
                               
 
 
                             </div>
 
                             </div>
 
                             <div class="table_wrap_w">
 
                             <div class="table_wrap_w">
第93行: 第91行:
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
                                     <div>customTexture</div>
+
                                     <div>customTexture(BitmapDescriptor customTexture)</div>
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
 
                                     <div>设置自定义纹理</div>
 
                                     <div>设置自定义纹理</div>
 
                                 </div>
 
                                 </div>
                               
 
 
                             </div>
 
                             </div>
 
                             <div class="table_wrap_w">
 
                             <div class="table_wrap_w">
第105行: 第102行:
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
                                     <div>dottedLine</div>
+
                                     <div>dottedLineType(PolylineDottedLineType polylineDottedLineType)</div>
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
 
                                     <div>设置Polyline的虚线类型</div>
 
                                     <div>设置Polyline的虚线类型</div>
 
                                 </div>
 
                                 </div>
                               
 
 
                             </div>
 
                             </div>
 
                             <div class="table_wrap_w">
 
                             <div class="table_wrap_w">
第117行: 第113行:
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
                                     <div>addOverlay</div>
+
                                     <div>addOverlay(OverlayOptions options)</div>
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
 
                                     <div>向地图添加一个overlay</div>
 
                                     <div>向地图添加一个overlay</div>
 
                                 </div>
 
                                 </div>
                               
 
 
                             </div>
 
                             </div>
 
                             <div class="table_wrap_w">
 
                             <div class="table_wrap_w">
第129行: 第124行:
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
                                     <div>flat</div>
+
                                     <div>flat(boolean flat)</div>
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
 
                                     <div>设置 marker设置是否平贴地图</div>
 
                                     <div>设置 marker设置是否平贴地图</div>
 
                                 </div>
 
                                 </div>
                               
 
 
                             </div>
 
                             </div>
 
                             <div class="table_wrap_w">
 
                             <div class="table_wrap_w">
第141行: 第135行:
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
                                     <div>anchor</div>
+
                                     <div>anchor(float anchorX, float anchorY)</div>
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
 
                                     <div>设置 marker 覆盖物的锚点比例,默认(0.5f, 1.0f)水平居中,垂直下对齐</div>
 
                                     <div>设置 marker 覆盖物的锚点比例,默认(0.5f, 1.0f)水平居中,垂直下对齐</div>
 
                                 </div>
 
                                 </div>
                               
 
 
                             </div>
 
                             </div>
 
                             <div class="table_wrap_w">
 
                             <div class="table_wrap_w">
第153行: 第146行:
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
                                     <div>icon</div>
+
                                     <div>icon(BitmapDescriptor icon)</div>
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
 
                                     <div>设置Marker图标</div>
 
                                     <div>设置Marker图标</div>
 
                                 </div>
 
                                 </div>
                               
 
 
                             </div>
 
                             </div>
 
                             <div class="table_wrap_w">
 
                             <div class="table_wrap_w">
第165行: 第157行:
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
                                     <div>position</div>
+
                                     <div>position(LatLng position)</div>
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
 
                                     <div>设置 marker 覆盖物的位置坐标</div>
 
                                     <div>设置 marker 覆盖物的位置坐标</div>
 
                                 </div>
 
                                 </div>
                               
 
 
                             </div>
 
                             </div>
 
                             <div class="table_wrap_w">
 
                             <div class="table_wrap_w">
第177行: 第168行:
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
                                     <div>rotate</div>
+
                                     <div>rotate(float rotate)</div>
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
 
                                     <div>设置 marker 覆盖物旋转角度,逆时针</div>
 
                                     <div>设置 marker 覆盖物旋转角度,逆时针</div>
 
                                 </div>
 
                                 </div>
                               
 
 
                             </div>
 
                             </div>
 
                             <div class="table_wrap_w">
 
                             <div class="table_wrap_w">
第189行: 第179行:
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
                                     <div>setPosition</div>
+
                                     <div>setPosition(LatLng position)</div>
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
 
                                     <div>设置Marker位置坐标</div>
 
                                     <div>设置Marker位置坐标</div>
 
                                 </div>
 
                                 </div>
                               
 
 
                             </div>
 
                             </div>
 
                             <div class="table_wrap_w">
 
                             <div class="table_wrap_w">
第201行: 第190行:
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
                                     <div>fromResource</div>
+
                                     <div>fromResource(int resourceId)</div>
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
 
                                     <div>根据资源Id创建不适配设备像素密度的bitmap描述信息</div>
 
                                     <div>根据资源Id创建不适配设备像素密度的bitmap描述信息</div>
 
                                 </div>
 
                                 </div>
                               
 
 
                             </div>
 
                             </div>
                         
 
 
                         </div>
 
                         </div>
 
                     </div>
 
                     </div>
 
                 </div>
 
                 </div>
 
 
             </div>
 
             </div>
 
         </div>
 
         </div>
第227行: 第213行:
 
             </div><!-- 安卓示例代码位置 -->
 
             </div><!-- 安卓示例代码位置 -->
 
             <div class="pre-wrap-w pre-wrap-w-and">
 
             <div class="pre-wrap-w pre-wrap-w-and">
                 <pre class="prettyprint prettyprinted pre-and">
+
                 <pre class="prettyprint prettyprinted pre-and">private void drawPolyLine() {
private void drawPolyLine() {
+
 
     List list = Arrays.asList(latlngs);
 
     List list = Arrays.asList(latlngs);
 
     List<LatLng> polylines = new ArrayList<>();
 
     List<LatLng> polylines = new ArrayList<>();
第256行: 第241行:
 
                 </div>
 
                 </div>
 
                 <div class="success">复制成功</div>
 
                 <div class="success">复制成功</div>
 
 
             </div>
 
             </div>
 
         </div>
 
         </div>
第267行: 第251行:
 
             </div><!-- 安卓示例代码位置 -->
 
             </div><!-- 安卓示例代码位置 -->
 
             <div class="pre-wrap-w pre-wrap-w-and">
 
             <div class="pre-wrap-w pre-wrap-w-and">
                 <pre class="prettyprint prettyprinted pre-and">
+
                 <pre class="prettyprint prettyprinted pre-and">/**
/**
+
 
* 循环进行移动逻辑
 
* 循环进行移动逻辑
 
*/
 
*/
第295行: 第278行:
 
                     double intercept = getInterception(slope, startPoint);
 
                     double intercept = getInterception(slope, startPoint);
 
                     double xMoveDistance =
 
                     double xMoveDistance =
                             isXReverse ? getXMoveDistance(slope) : -1 * getXMoveDistance(slope);
+
                             isXReverse&nbsp;? getXMoveDistance(slope)&nbsp;: -1 * getXMoveDistance(slope);
 
                     double yMoveDistance =
 
                     double yMoveDistance =
                             isYReverse ? getYMoveDistance(slope) : -1 * getYMoveDistance(slope);
+
                             isYReverse&nbsp;? getYMoveDistance(slope)&nbsp;: -1 * getYMoveDistance(slope);
  
 
                     for (double j = startPoint.latitude, k = startPoint.longitude;
 
                     for (double j = startPoint.latitude, k = startPoint.longitude;
                            !((j > endPoint.latitude)
+
                          &nbsp;!((j > endPoint.latitude)
 
                                     ^ isYReverse)
 
                                     ^ isYReverse)
                                 && !((k > endPoint.longitude)
+
                                 &&&nbsp;!((k > endPoint.longitude)
 
                                                 ^ isXReverse); ) {
 
                                                 ^ isXReverse); ) {
 
                         LatLng latLng = null;
 
                         LatLng latLng = null;
第351行: 第334行:
 
                 </div>
 
                 </div>
 
                 <div class="success">复制成功</div>
 
                 <div class="success">复制成功</div>
 
 
             </div>
 
             </div>
 
         </div>
 
         </div>
 
 
     </div>
 
     </div>
 
     <div class="ios-wrap wrap" style="display: none;">
 
     <div class="ios-wrap wrap" style="display: none;">
第393行: 第374行:
 
                     </div>
 
                     </div>
 
                     <div class="wrap_right_nav_r">下载源码</div><!-- IOS源码地址 -->
 
                     <div class="wrap_right_nav_r">下载源码</div><!-- IOS源码地址 -->
                     <div class="github-url-ios">//mapopen-website-wiki.bj.bcebos.com/demos/iosVideos/iOS示例中心Demo.zip</div>
+
                     <div class="github-url-ios">//mapopen-website-wiki.bj.bcebos.com/demos/iosVideos/iOS示例中心Demo.zip
 +
                    </div>
 
                 </div>
 
                 </div>
 
                 <div class="wrap_table">
 
                 <div class="wrap_table">
第410行: 第392行:
 
                             <div class="table_wrap_w">
 
                             <div class="table_wrap_w">
 
                                 <div>
 
                                 <div>
                                     <div class="table-wrap-className">BMKPointAnnotation </div>
+
                                     <div class="table-wrap-className">BMKPointAnnotation</div>
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
第421行: 第403行:
 
                             <div class="table_wrap_w">
 
                             <div class="table_wrap_w">
 
                                 <div>
 
                                 <div>
                                     <div class="table-wrap-className">BMKPointAnnotation </div>
+
                                     <div class="table-wrap-className">BMKPointAnnotation</div>
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
第432行: 第414行:
 
                             <div class="table_wrap_w">
 
                             <div class="table_wrap_w">
 
                                 <div>
 
                                 <div>
                                     <div class="table-wrap-className">BMKPointAnnotation </div>
+
                                     <div class="table-wrap-className">BMKPointAnnotation</div>
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
第443行: 第425行:
 
                             <div class="table_wrap_w">
 
                             <div class="table_wrap_w">
 
                                 <div>
 
                                 <div>
                                     <div class="table-wrap-className">BMKPinAnnotationView </div>
+
                                     <div class="table-wrap-className">BMKPinAnnotationView</div>
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
                                     <div>- (id)initWithAnnotation:(id <BMKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier;</div>
+
                                     <div>- (id)initWithAnnotation:(id &lt;BMKAnnotation&gt;)annotation
 +
                                        reuseIdentifier:(NSString *)reuseIdentifier;</div>
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
第454行: 第437行:
 
                             <div class="table_wrap_w">
 
                             <div class="table_wrap_w">
 
                                 <div>
 
                                 <div>
                                     <div class="table-wrap-className">BMKPolygon </div>
+
                                     <div class="table-wrap-className">BMKPolygon</div>
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
                                     <div>+ (BMKPolygon *)polygonWithCoordinates:(CLLocationCoordinate2D *)coords count:(NSUInteger)count;</div>
+
                                     <div>+ (BMKPolygon *)polygonWithCoordinates:(CLLocationCoordinate2D *)coords
 +
                                        count:(NSUInteger)count;</div>
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
第465行: 第449行:
 
                             <div class="table_wrap_w">
 
                             <div class="table_wrap_w">
 
                                 <div>
 
                                 <div>
                                     <div class="table-wrap-className">BMKPolygonView </div>
+
                                     <div class="table-wrap-className">BMKPolygonView</div>
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
                                     <div>- (id)initWithOverlay:(id <BMKOverlay>)overlay;</div>
+
                                     <div>- (id)initWithOverlay:(id &lt;BMKOverlay&gt;)overlay;</div>
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
第476行: 第460行:
 
                             <div class="table_wrap_w">
 
                             <div class="table_wrap_w">
 
                                 <div>
 
                                 <div>
                                     <div class="table-wrap-className">BMKMapView </div>
+
                                     <div class="table-wrap-className">BMKMapView</div>
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
                                     <div>- (void)addAnnotation:(id <BMKAnnotation>)annotation;</div>
+
                                     <div>- (void)addAnnotation:(id &lt;BMKAnnotation&gt;)annotation;</div>
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
第487行: 第471行:
 
                             <div class="table_wrap_w">
 
                             <div class="table_wrap_w">
 
                                 <div>
 
                                 <div>
                                     <div class="table-wrap-className">UIView </div>
+
                                     <div class="table-wrap-className">UIView</div>
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
                                     <div>+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^ __nullable)(BOOL finished))completion API_AVAILABLE(ios(4.0));</div>
+
                                     <div>+ (void)animateWithDuration:(NSTimeInterval)duration
 +
                                        delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options
 +
                                        animations:(void (^)(void))animations completion:(void (^ __nullable)(BOOL
 +
                                        finished))completion API_AVAILABLE(ios(4.0));</div>
 
                                 </div>
 
                                 </div>
 
                                 <div>
 
                                 <div>
第499行: 第486行:
 
                     </div>
 
                     </div>
 
                 </div>
 
                 </div>
 
 
             </div>
 
             </div>
 
         </div>
 
         </div>
第513行: 第499行:
 
                 <div>Objective-C</div>
 
                 <div>Objective-C</div>
 
             </div>
 
             </div>
           
 
 
             <div class="pre-wrap-w pre-wrap-w-ios code_container">
 
             <div class="pre-wrap-w pre-wrap-w-ios code_container">
 
                 <!-- ios示例代码位置 -->
 
                 <!-- ios示例代码位置 -->
                 <pre class="prettyprint prettyprinted pre-ios">
+
                 <pre class="prettyprint prettyprinted pre-ios">#pragma mark - 动画相关
#pragma mark - 动画相关
+
 
- (void)startAnimation {
 
- (void)startAnimation {
 
     double speed = 80.0 / 3.6;
 
     double speed = 80.0 / 3.6;
第524行: 第508行:
 
     [UIView animateWithDuration:node.distance / speed
 
     [UIView animateWithDuration:node.distance / speed
 
     delay:0.0 options:UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction animations:^(void) {
 
     delay:0.0 options:UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction animations:^(void) {
         [self.annotation setCoordinate:((BMKSportNode *)self.sportNodes[(self.currentIndex + 1) % self.sportNodeNum]).coordinate];
+
         [self.annotation setCoordinate:((BMKSportNode *)self.sportNodes[(self.currentIndex + 1)&nbsp;% self.sportNodeNum]).coordinate];
 
     } completion:^(BOOL finished) {
 
     } completion:^(BOOL finished) {
 
         if (!self.stopAnimation) {
 
         if (!self.stopAnimation) {
 
             self.currentIndex ++;
 
             self.currentIndex ++;
             self.currentIndex %= self.sportNodes.count;
+
             self.currentIndex&nbsp;%= self.sportNodes.count;
 
             __weak id weakSelf = self;
 
             __weak id weakSelf = self;
 
             [[NSOperationQueue mainQueue] addOperationWithBlock:^{
 
             [[NSOperationQueue mainQueue] addOperationWithBlock:^{
第551行: 第535行:
 
                 <div>Objective-C</div>
 
                 <div>Objective-C</div>
 
             </div>
 
             </div>
           
 
 
             <div class="pre-wrap-w pre-wrap-w-ios code_container">
 
             <div class="pre-wrap-w pre-wrap-w-ios code_container">
 
                 <!-- ios示例代码位置 -->
 
                 <!-- ios示例代码位置 -->
                 <pre class="prettyprint prettyprinted pre-ios">
+
                 <pre class="prettyprint prettyprinted pre-ios">#pragma mark - SportPath
#pragma mark - SportPath
+
 
- (void)fetchSportNodes {
 
- (void)fetchSportNodes {
 
     self.sumDistance = 0;
 
     self.sumDistance = 0;
第565行: 第547行:
 
         NSDictionary *current = array[i];
 
         NSDictionary *current = array[i];
 
         CLLocationCoordinate2D startCoor = CLLocationCoordinate2DMake([current[@"lat"] doubleValue], [current[@"lon"] doubleValue]);
 
         CLLocationCoordinate2D startCoor = CLLocationCoordinate2DMake([current[@"lat"] doubleValue], [current[@"lon"] doubleValue]);
         NSDictionary *next = array[(i + 1) % array.count];
+
         NSDictionary *next = array[(i + 1)&nbsp;% array.count];
 
         CLLocationCoordinate2D endCoor = CLLocationCoordinate2DMake([next[@"lat"] doubleValue], [next[@"lon"] doubleValue]);
 
         CLLocationCoordinate2D endCoor = CLLocationCoordinate2DMake([next[@"lat"] doubleValue], [next[@"lon"] doubleValue]);
 
         CLLocation *begin = [[CLLocation alloc] initWithLatitude:startCoor.latitude longitude:startCoor.longitude];
 
         CLLocation *begin = [[CLLocation alloc] initWithLatitude:startCoor.latitude longitude:startCoor.longitude];

2020年6月1日 (一) 17:22的版本

平滑移动
功能场景
出行、运动健康类app中动态展示小车、用户的轨迹变化。
Android
iOS
//mapopen-website-wiki.bj.bcebos.com/demos/AndroidVideos/Android平滑移动.mp4
1590746640|//mapopen-website-wiki.bj.bcebos.com/demos/qrcodes/平滑移动.png
扫码体验
使用产品
Android地图SDK|/index.php?title=androidsdk
下载源码
//mapopen-website-wiki.bj.bcebos.com/demos/iosVideos/iOS示例中心Demo.zip
核心接口
接口
描述
PolylineOptions
points(List<LatLng> points)
设置Polyline坐标点列表
PolylineOptions
width(int width)
设置Polyline宽度
PolylineOptions
customTexture(BitmapDescriptor customTexture)
设置自定义纹理
PolylineOptions
dottedLineType(PolylineDottedLineType polylineDottedLineType)
设置Polyline的虚线类型
BaiduMap
addOverlay(OverlayOptions options)
向地图添加一个overlay
MarkerOptions
flat(boolean flat)
设置 marker设置是否平贴地图
MarkerOptions
anchor(float anchorX, float anchorY)
设置 marker 覆盖物的锚点比例,默认(0.5f, 1.0f)水平居中,垂直下对齐
MarkerOptions
icon(BitmapDescriptor icon)
设置Marker图标
MarkerOptions
position(LatLng position)
设置 marker 覆盖物的位置坐标
MarkerOptions
rotate(float rotate)
设置 marker 覆盖物旋转角度,逆时针
Marker
setPosition(LatLng position)
设置Marker位置坐标
BitmapDescriptorFactory
fromResource(int resourceId)
根据资源Id创建不适配设备像素密度的bitmap描述信息
核心代码
1.绘制轨迹
JAVA
private void drawPolyLine() {
    List list = Arrays.asList(latlngs);
    List<LatLng> polylines = new ArrayList<>();
    polylines.addAll(list);
    polylines.add(latlngs[0]);
    // 绘制纹理PolyLine
    PolylineOptions polylineOptions =
            new PolylineOptions().points(polylines).width(25).customTexture(mGreenTexture)
                    .dottedLine(true);
    mPolyline = (Polyline) mBaiduMap.addOverlay(polylineOptions);

    // 添加小车marker
    OverlayOptions markerOptions = new MarkerOptions()
            .flat(true)
            .anchor(0.5f, 0.5f)
            .icon(mBitmapCar).
                    position(polylines.get(0))
            .rotate((float) getAngle(0));
    mMoveMarker = (Marker) mBaiduMap.addOverlay(markerOptions);

}
                     
                
复制
深色
复制成功
2.移动小车
JAVA
/**
* 循环进行移动逻辑
*/
public void moveLooper() {
    new Thread() {
        public void run() {
            while (true) {
                for (int i = 0; i < latlngs.length - 1; i++) {
                    final LatLng startPoint = latlngs[i];
                    final LatLng endPoint = latlngs[i + 1];
                    mMoveMarker.setPosition(startPoint);
                    mHandler.post(new Runnable() {
                        @Override
                        public void run() {
                            // refresh marker's rotate
                            if (mMapView == null) {
                                return;
                            }
                            mMoveMarker.setRotate((float) getAngle(startPoint, endPoint));
                        }
                    });
                    double slope = getSlope(startPoint, endPoint);
                    // 是不是正向的标示
                    boolean isYReverse = (startPoint.latitude > endPoint.latitude);
                    boolean isXReverse = (startPoint.longitude > endPoint.longitude);
                    double intercept = getInterception(slope, startPoint);
                    double xMoveDistance =
                            isXReverse ? getXMoveDistance(slope) : -1 * getXMoveDistance(slope);
                    double yMoveDistance =
                            isYReverse ? getYMoveDistance(slope) : -1 * getYMoveDistance(slope);

                    for (double j = startPoint.latitude, k = startPoint.longitude;
                            !((j > endPoint.latitude)
                                    ^ isYReverse)
                                && !((k > endPoint.longitude)
                                                ^ isXReverse); ) {
                        LatLng latLng = null;

                        if (slope == Double.MAX_VALUE) {
                            latLng = new LatLng(j, k);
                            j = j - yMoveDistance;
                        } else if (slope == 0.0) {
                            latLng = new LatLng(j, k - xMoveDistance);
                            k = k - xMoveDistance;
                        } else {
                            latLng = new LatLng(j, (j - intercept) / slope);
                            j = j - yMoveDistance;
                        }

                        final LatLng finalLatLng = latLng;
                        if (finalLatLng.latitude == 0 && finalLatLng.longitude == 0) {
                            continue;
                        }
                        mHandler.post(new Runnable() {
                            @Override
                            public void run() {
                                if (mMapView == null) {
                                    return;
                                }
                                mMoveMarker.setPosition(finalLatLng);
                                // 设置 Marker 覆盖物的位置坐标,并同步更新与Marker关联的InfoWindow的位置坐标.
                                mMoveMarker.setPositionWithInfoWindow(finalLatLng);
                            }
                        });
                        try {
                            Thread.sleep(TIME_INTERVAL);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        }

    }.start();
}
               
                
复制
深色
复制成功
  • 文档根本没法用

  • 文档水平很差

  • 文档水平一般

  • 文档不错

  • 文档写的很好

如发现文档错误,或对此文档有更好的建议,请在下方反馈。问题咨询请前往反馈平台提交工单咨询。

提交反馈

拖动标注工具

添加矩形标注

添加箭头标注

完成

取消