Search in sources :

Example 21 with LatLng

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

the class RouteActivity method init.

/**
 * 初始化AMap对象
 */
private void init() {
    if (aMap == null) {
        aMap = mapView.getMap();
    }
    registerListener();
    aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(Config.getLatitude(), Config.getLongitude()), 13));
    mUiSettings = aMap.getUiSettings();
    mUiSettings.setScaleControlsEnabled(true);
    mRouteSearch = new RouteSearch(this);
    mRouteSearch.setRouteSearchListener(this);
    mBottomLayout = (RelativeLayout) findViewById(R.id.bottom_layout);
    mBusResultLayout = (LinearLayout) findViewById(R.id.bus_result);
    mRouteTimeDes = (TextView) findViewById(R.id.firstline);
    mRouteDetailDes = (TextView) findViewById(R.id.secondline);
    mDrive = (ImageView) findViewById(R.id.route_drive);
    mBus = (ImageView) findViewById(R.id.route_bus);
    mWalk = (ImageView) findViewById(R.id.route_walk);
    mBusResultList = (ListView) findViewById(R.id.bus_result_list);
}
Also used : LatLng(com.amap.api.maps.model.LatLng) RouteSearch(com.amap.api.services.route.RouteSearch)

Example 22 with LatLng

use of com.amap.api.maps.model.LatLng in project MVVM-Demo by lilongweidev.

the class MapFragment method switchMapCenter.

/**
 * 切换地图中心
 */
private void switchMapCenter(GeocodeResult geocodeResult, LatLonPoint latLonPoint) {
    // 显示解析后的坐标,
    double latitude = latLonPoint.getLatitude();
    double longitude = latLonPoint.getLongitude();
    // 创建经纬度对象
    LatLng latLng = new LatLng(latitude, longitude);
    // 改变地图中心点
    // 参数依次是:视角调整区域的中心点坐标、希望调整到的缩放级别、俯仰角0°~45°(垂直与地图时为0)、偏航角 0~360° (正北方为0)
    CameraUpdate mCameraUpdate = CameraUpdateFactory.newCameraPosition(new CameraPosition(latLng, 18, 30, 0));
    // 在地图上添加marker
    aMap.addMarker(new MarkerOptions().position(latLng).title(geocodeResult.getGeocodeQuery().getLocationName()).snippet("DefaultMarker"));
    // 动画移动
    aMap.animateCamera(mCameraUpdate);
    // 移动地图后通过坐标转地址,触发onRegeocodeSearched回调,在这个回调里去查询天气
    RegeocodeQuery query = new RegeocodeQuery(latLonPoint, 20, GeocodeSearch.AMAP);
    geocoderSearch.getFromLocationAsyn(query);
}
Also used : CameraPosition(com.amap.api.maps.model.CameraPosition) MarkerOptions(com.amap.api.maps.model.MarkerOptions) LatLng(com.amap.api.maps.model.LatLng) RegeocodeQuery(com.amap.api.services.geocoder.RegeocodeQuery) CameraUpdate(com.amap.api.maps.CameraUpdate)

Example 23 with LatLng

use of com.amap.api.maps.model.LatLng in project uav_mobile_app by jiushuokj.

the class MainActivity method startRecordingTrace.

private void startRecordingTrace() {
    if (makeTraceDisposable != null && !makeTraceDisposable.isDisposed()) {
        return;
    }
    Log.i(TAG, "startRecordingTrace: " + "开始记录航线");
    makeTraceDisposable = Observable.interval(500, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer<Long>() {

        @Override
        public void accept(Long aLong) throws Exception {
            if (!DoubleComparer.considerEqual(droneLocationLatForTrace, mFlightController.getState().getAircraftLocation().getLatitude(), DELTA) || !DoubleComparer.considerEqual(droneLocationLngForTrace, mFlightController.getState().getAircraftLocation().getLongitude(), DELTA)) {
                // 坐标转换
                // final LatLng oldLatlng = new LatLng(droneLocationLatForTrace, droneLocationLngForTrace);
                final LatLng oldLatlng = CoordinateTransUtils.getGDLatLng(droneLocationLatForTrace, droneLocationLngForTrace);
                droneLocationLatForTrace = mFlightController.getState().getAircraftLocation().getLatitude();
                droneLocationLngForTrace = mFlightController.getState().getAircraftLocation().getLongitude();
                // 坐标转换
                // final LatLng newLatlng = new LatLng(droneLocationLatForTrace, droneLocationLngForTrace);
                final LatLng newLatlng = CoordinateTransUtils.getGDLatLng(droneLocationLatForTrace, droneLocationLngForTrace);
                Polyline polyline = aMap.addPolyline(new PolylineOptions().addAll(Arrays.asList(oldLatlng, newLatlng)).width(4).color(Color.argb(255, 255, 1, 1)));
                mTracePolylines.put(mTracePolylines.size(), polyline);
                Log.d(TAG, "startRecordingTrace: " + mTracePolylines.size() + "次轨迹");
            }
        }
    });
}
Also used : Consumer(dji.thirdparty.io.reactivex.functions.Consumer) Polyline(com.amap.api.maps.model.Polyline) LatLng(com.amap.api.maps.model.LatLng) PolylineOptions(com.amap.api.maps.model.PolylineOptions)

Example 24 with LatLng

use of com.amap.api.maps.model.LatLng in project uav_mobile_app by jiushuokj.

the class MainActivity method updateDroneLocation.

private void updateDroneLocation() {
    // 坐标转换
    // LatLng pos = new LatLng(droneLocationLat, droneLocationLng);
    LatLng pos = CoordinateTransUtils.getGDLatLng(droneLocationLat, droneLocationLng);
    // Create MarkerOptions object
    final MarkerOptions markerOptions = new MarkerOptions().position(pos).icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_compass_aircraft));
    runOnUiThread(new Runnable() {

        @Override
        public void run() {
            if (droneMarker != null) {
                droneMarker.remove();
            }
            if (checkGpsCoordination(droneLocationLat, droneLocationLng)) {
                droneMarker = aMap.addMarker(markerOptions);
                // 图标根据机头方向旋转
                droneMarker.setRotateAngle(360 - (float) droneHeadDirection);
                // 显示飞机纬度经度
                updateAircraftLocationText();
            }
        }
    });
}
Also used : MarkerOptions(com.amap.api.maps.model.MarkerOptions) LatLng(com.amap.api.maps.model.LatLng)

Example 25 with LatLng

use of com.amap.api.maps.model.LatLng in project uav_mobile_app by jiushuokj.

the class CoordinateTransUtils method getDJILatLng.

// GCJ-02 to WGS-84
public static LatLng getDJILatLng(double latitude, double longitude) {
    LatLonPoint dev = calDev(latitude, longitude);
    double retLat = latitude - dev.getLatitude();
    double retLon = longitude - dev.getLongitude();
    for (int i = 0; i < 1; i++) {
        dev = calDev(retLat, retLon);
        retLat = latitude - dev.getLatitude();
        retLon = longitude - dev.getLongitude();
    }
    return new LatLng(retLat, retLon);
}
Also used : LatLng(com.amap.api.maps.model.LatLng) LatLonPoint(com.amap.api.services.core.LatLonPoint) DPoint(com.amap.api.location.DPoint) LatLonPoint(com.amap.api.services.core.LatLonPoint)

Aggregations

LatLng (com.amap.api.maps.model.LatLng)48 LatLonPoint (com.amap.api.services.core.LatLonPoint)15 MarkerOptions (com.amap.api.maps.model.MarkerOptions)9 ArrayList (java.util.ArrayList)7 LatLngBounds (com.amap.api.maps.model.LatLngBounds)6 Marker (com.amap.api.maps.model.Marker)6 Bitmap (android.graphics.Bitmap)4 Point (android.graphics.Point)4 CameraUpdate (com.amap.api.maps.CameraUpdate)4 PolylineOptions (com.amap.api.maps.model.PolylineOptions)4 TextView (android.widget.TextView)3 CameraPosition (com.amap.api.maps.model.CameraPosition)3 Polyline (com.amap.api.maps.model.Polyline)3 SuppressLint (android.annotation.SuppressLint)2 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 DPoint (com.amap.api.location.DPoint)2