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);
}
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);
}
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() + "次轨迹");
}
}
});
}
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();
}
}
});
}
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);
}
Aggregations