逗人,與animateCamera到屏幕位置x地圖標記位置,Y
我具有覆蓋整個屏幕的地圖視圖。在它的頂部,有一個查看尋呼機。 視圖尋呼機由兩部分組成,頂部40%和底部60%,頂部只是一個透明視圖。
在滑動視圖尋呼機時,地圖上顯示的標記應該位於透明頂視圖中間的40%。
此圖片描述的故事:
如何實現這一目標? 我想這一點,但沒有運氣:
public void FollowVehicle(clsFollowMode vehicle){
final LatLng vehiclePosition = new LatLng(vehicle.getLatitude(), vehicle.getLongtitude());
Marker vehicleMarker = myGMap.addMarker(new MarkerOptions()
.position(vehiclePosition)
.title(vehicle.getDeviceName())
.snippet(String.valueOf(vehicle.getSpeed()))
.icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_vehicle_follow)));
float zoom_lvl = myGMap.getCameraPosition().zoom;
double dpPerdegree = 256.0*Math.pow(2, zoom_lvl)/170.0;
double screen_height = (double) mapContainer.getHeight();
double screen_height_30p = -20.0*screen_height/100.0;
double degree_30p = screen_height_30p/dpPerdegree;
LatLng centerlatlng = new LatLng(vehiclePosition.latitude + degree_30p, vehiclePosition.longitude);
myGMap.animateCamera(CameraUpdateFactory.newLatLngZoom(centerlatlng, 15), 1000, null);
}
任何幫助嗎?上述解決方案found here。
問候,
那麼是什麼問題?沒有運氣,你是什麼意思?它現在如何工作? –
當尋呼機第一次打開時,它不會集中到第一個標記,但當我移動到其他頁面時,進一步,當我第二次再次返回到第一頁時,它工作正常。此外,頁面與另一頁面之間的縮放變化導致下一個標記的故障集中。我認爲我在縮放級別的這段代碼(我猜)時會遇到問題。任何建議?我做錯了什麼? – alawibh