Google Maps视图闪烁

时间:2019-05-20 08:11:34

标签: java android google-maps

我想使视图居中,以便标记位于底部。我这样做:

public static void centerToCurrentLocation(GoogleMap mMap, LatLng currentLocation, RelativeLayout relativeLayout, Display display) {

    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(currentLocation, 16));

    Projection projection = mMap.getProjection();
    Point mappoint = mMap.getProjection().toScreenLocation(currentLocation);
    Point size = new Point();
    display.getSize(size);
    int width = size.x;
    int height = size.y;

    int poss = (int) (relativeLayout.getHeight() * 0.1);
    int diss = (relativeLayout.getHeight() - poss) - mappoint.y;
    mappoint.set(mappoint.x, mappoint.y - diss);

    Log.d("mapPoint ", mappoint.x + " " + mappoint.y + " " + relativeLayout.getHeight() + " " + diss + " " + poss);
    Log.e("Width", "" + width);
    Log.e("height", "" + height);

    mMap.moveCamera(CameraUpdateFactory.newLatLng(mMap.getProjection().fromScreenLocation(mappoint)));
}

但是,当我的位置更改时,我的观点闪烁了,应该做些什么以使其更好地工作

0 个答案:

没有答案
相关问题