Search in sources :

Example 1 with LatLng

use of com.amap.api.maps.model.LatLng in project Dxditor by kimi2009.

the class MapPageActivity method jumpPoint.

/**
 * marker点击时跳动一下
 */
public void jumpPoint(final Marker marker) {
    final Handler handler = new Handler();
    final long start = SystemClock.uptimeMillis();
    Projection proj = aMap.getProjection();
    final LatLng markerLatlng = marker.getPosition();
    Point markerPoint = proj.toScreenLocation(markerLatlng);
    markerPoint.offset(0, -100);
    final LatLng startLatLng = proj.fromScreenLocation(markerPoint);
    final long duration = 1500;
    final Interpolator interpolator = new BounceInterpolator();
    handler.post(new Runnable() {

        @Override
        public void run() {
            long elapsed = SystemClock.uptimeMillis() - start;
            float t = interpolator.getInterpolation((float) elapsed / duration);
            double lng = t * markerLatlng.longitude + (1 - t) * startLatLng.longitude;
            double lat = t * markerLatlng.latitude + (1 - t) * startLatLng.latitude;
            marker.setPosition(new LatLng(lat, lng));
            if (t < 1.0) {
                handler.postDelayed(this, 16);
            }
        }
    });
}
Also used : BounceInterpolator(android.view.animation.BounceInterpolator) Handler(android.os.Handler) Projection(com.amap.api.maps.Projection) BounceInterpolator(android.view.animation.BounceInterpolator) Interpolator(android.view.animation.Interpolator) LatLng(com.amap.api.maps.model.LatLng) Point(android.graphics.Point)

Example 2 with LatLng

use of com.amap.api.maps.model.LatLng in project Dxditor by kimi2009.

the class MapPageActivity method onResume.

/**
 * 方法必须重写
 */
@Override
protected void onResume() {
    super.onResume();
    LatLng llC = new LatLng(35, 115);
    LatLng llD = new LatLng(30, 120);
    LatLngBounds bounds = new LatLngBounds.Builder().include(llC).include(llD).build();
    aMap.moveCamera(CameraUpdateFactory.newLatLngBoundsRect(bounds, 10, 10, 10, 10));
    mapView.onResume();
}
Also used : LatLngBounds(com.amap.api.maps.model.LatLngBounds) LatLng(com.amap.api.maps.model.LatLng)

Example 3 with LatLng

use of com.amap.api.maps.model.LatLng in project Dxditor by kimi2009.

the class MapPageActivity method convert.

/**
 * 高德坐标转换
 *
 * @param context
 * @param latStr  纬度
 * @param lngStr  经度
 * @return
 */
private LatLng convert(Context context, String latStr, String lngStr) {
    if (!"".equals(latStr) && latStr != null && !"".equals(lngStr) && lngStr != null) {
        double lat = 0.0;
        double lon = 0.0;
        lat = Double.parseDouble(latStr);
        lon = Double.parseDouble(lngStr);
        CoordinateConverter converter = new CoordinateConverter(context);
        // CoordType.GPS 待转换坐标类型
        converter.from(CoordType.GPS);
        // sourceLatLng待转换坐标点
        converter.coord(new LatLng(lat, lon));
        // 执行转换操作
        LatLng desLatLng = converter.convert();
        return desLatLng;
    } else {
        Toast.makeText(MapPageActivity.this, "GPS数据错误", Toast.LENGTH_LONG).show();
        return null;
    }
}
Also used : CoordinateConverter(com.amap.api.maps.CoordinateConverter) LatLng(com.amap.api.maps.model.LatLng)

Example 4 with LatLng

use of com.amap.api.maps.model.LatLng in project LivingInCampus by DulCoder.

the class AMapServicesUtil method convertArrList.

public static ArrayList<LatLng> convertArrList(List<LatLonPoint> shapes) {
    ArrayList<LatLng> lineShapes = new ArrayList<LatLng>();
    for (LatLonPoint point : shapes) {
        LatLng latLngTemp = AMapServicesUtil.convertToLatLng(point);
        lineShapes.add(latLngTemp);
    }
    return lineShapes;
}
Also used : ArrayList(java.util.ArrayList) LatLng(com.amap.api.maps.model.LatLng) LatLonPoint(com.amap.api.services.core.LatLonPoint)

Example 5 with LatLng

use of com.amap.api.maps.model.LatLng in project LivingInCampus by DulCoder.

the class BusRouteOverlay method addWalkPolyLineByLatLonPoints.

/**
 */
private void addWalkPolyLineByLatLonPoints(LatLonPoint pointFrom, LatLonPoint pointTo) {
    LatLng latLngFrom = AMapUtil.convertToLatLng(pointFrom);
    LatLng latLngTo = AMapUtil.convertToLatLng(pointTo);
    addWalkPolyline(latLngFrom, latLngTo);
}
Also used : LatLng(com.amap.api.maps.model.LatLng)

Aggregations

LatLng (com.amap.api.maps.model.LatLng)33 LatLonPoint (com.amap.api.services.core.LatLonPoint)11 MarkerOptions (com.amap.api.maps.model.MarkerOptions)6 Marker (com.amap.api.maps.model.Marker)5 Bitmap (android.graphics.Bitmap)4 Point (android.graphics.Point)4 ArrayList (java.util.ArrayList)4 TextView (android.widget.TextView)3 LatLngBounds (com.amap.api.maps.model.LatLngBounds)3 View (android.view.View)2 BounceInterpolator (android.view.animation.BounceInterpolator)2 Interpolator (android.view.animation.Interpolator)2 ImageView (android.widget.ImageView)2 BindView (butterknife.BindView)2 AMap (com.amap.api.maps.AMap)2 CameraUpdate (com.amap.api.maps.CameraUpdate)2 Projection (com.amap.api.maps.Projection)2 CameraPosition (com.amap.api.maps.model.CameraPosition)2 SuggestionCity (com.amap.api.services.core.SuggestionCity)2 WalkStep (com.amap.api.services.route.WalkStep)2