地图中心点移动到屏幕上的3/1
This commit is contained in:
parent
0aac301e3c
commit
a1a17b2a63
44
app/src/main/java/com/navinfo/outdoor/util/MapManager.java
Normal file
44
app/src/main/java/com/navinfo/outdoor/util/MapManager.java
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
package com.navinfo.outdoor.util;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.tencent.tencentmap.mapsdk.maps.CameraUpdate;
|
||||||
|
import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
|
||||||
|
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
||||||
|
import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition;
|
||||||
|
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||||
|
|
||||||
|
public class MapManager {
|
||||||
|
private static MapManager instance;
|
||||||
|
private TencentMap tencentMap;
|
||||||
|
private Context mContext;
|
||||||
|
|
||||||
|
public static MapManager getInstance() {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new MapManager();
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init(Context mContext, TencentMap map) {
|
||||||
|
this.mContext = mContext;
|
||||||
|
this.tencentMap = map;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TencentMap getTencentMap() {
|
||||||
|
return tencentMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将地图顶部中心定位到指定位置
|
||||||
|
public void animateMapLocation2TopCenter(LatLng latLng, float x, float y) {
|
||||||
|
if (tencentMap!=null) {
|
||||||
|
tencentMap.setMapCenterAndScale(x, y, tencentMap.getCameraPosition().zoom);
|
||||||
|
CameraUpdate cameraSigma = CameraUpdateFactory.newCameraPosition(new CameraPosition(
|
||||||
|
latLng, //中心点坐标,地图目标经纬度
|
||||||
|
tencentMap.getCameraPosition().zoom, //目标缩放级别
|
||||||
|
tencentMap.getCameraPosition().tilt, //目标倾斜角[0.0 ~ 45.0] (垂直地图时为0)
|
||||||
|
tencentMap.getCameraPosition().bearing)); //目标旋转角 0~360° (正北方为0)
|
||||||
|
tencentMap.animateCamera(cameraSigma);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user