mapview刷新

问题描述 投票:3回答:2

我的appn中有一个mapview。当页面加载时,我会在地图上显示一些点。我在该页面中也有一个搜索按钮。因此,在我提供搜索内容并单击搜索按钮后,地图不会刷新。只有当我们触摸地图上的任何地方时,它才会刷新。我也给了mapview.invalidate()。还是行不通...

知道为什么会出现这个问题吗?

android google-maps android-mapview
2个回答
11
投票

我们要给..

mapview.invalidate()

显示叠加时我遇到了一些问题。所以它没有提前工作。现在它完美的工作..


0
投票

而不是MapView使用SupportMapFragment

       <fragment
                xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                android:id="@+id/lite_map"
                android:name="com.google.android.gms.maps.SupportMapFragment"
                android:layout_width="match_parent"
                android:layout_height="80dp" />

然后使用getMapAsync()方法初始化片段并获取地图:

    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.lite_map);
    mapFragment.getMapAsync(this);

下一个实现与MapView相同 - 在mapReady上处理回调方法:

@Override
public void onMapReady(GoogleMap googleMap) {

    map = googleMap;

    updateMapCoordinates();

}
© www.soinside.com 2019 - 2024. All rights reserved.