Coder Social home page Coder Social logo

android-smooth-move's Introduction

本工程为基于高德地图Android SDK进行封装,实现了点沿线平滑移动的效果。

前述

功能描述

基于3D地图SDK进行封装,实现了Marker点在线上进行平滑移动的例子。

效果图如下

Screenshot

扫一扫安装##

Screenshot

使用方法##

###1:配置搭建AndroidSDK工程###

###2:思路介绍###

  • 计算斜率
 /**
  * 算斜率
  */
private double getSlope(LatLng fromPoint, LatLng toPoint) {
    if (toPoint.longitude == fromPoint.longitude) {
        return Double.MAX_VALUE;
    }
    double slope = ((toPoint.latitude - fromPoint.latitude) / (toPoint.longitude - fromPoint.longitude));
    return slope;

}
  • 计算移动距离
/**
 * 计算每次移动的距离
 */
private double getMoveDistance(double slope) {
    if (slope == Double.MAX_VALUE||slope==0) {
        return DISTANCE;
    }
    return Math.abs((DISTANCE * slope) / Math.sqrt(1 + slope * slope));
}
  • 计算marker角度
/**
 * 根据点获取图标转的角度
 */
private double getAngle(int startIndex) {
    if ((startIndex + 1) >= mVirtureRoad.getPoints().size()) {
        throw new RuntimeException("index out of bonds");
    }
    LatLng startPoint = mVirtureRoad.getPoints().get(startIndex);
    LatLng endPoint = mVirtureRoad.getPoints().get(startIndex + 1);
    return getAngle(startPoint, endPoint);
}

android-smooth-move's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.