地图视图刷新

发布于 2024-10-10 06:45:03 字数 163 浏览 0 评论 0原文

我的应用程序中有一个地图视图。加载页面时,我在地图上显示一些点。 我在该页面上还有一个搜索按钮。因此,在我提供搜索内容并单击搜索按钮后,地图不会刷新。仅当我们触摸地图上的任何位置时它才会刷新。我也给出了mapview.invalidate()。仍然无法正常工作...

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

I have a mapview in my appn. I show some points on the map when the page gets loaded.
I also have a search button in that page. So after I give something to search and click search button, map doesnt gets refreshed. It gets refreshed only when we touch anywhere on the map. I have given mapview.invalidate() also. Still not working...

Any idea why this problem occurs?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

佞臣 2024-10-17 06:45:03

我们必须给予..

mapview.invalidate()

我在显示叠加层时遇到了一些问题。所以之前没有发挥作用。现在它完美工作..

We have to give..

mapview.invalidate()

I had some problem while displaying overlays. So it didnt work earlier. Now its perfectly working..

嗼ふ静 2024-10-17 06:45:03

使用 SupportMapFragment 代替 MapView

       <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 相同 - 处理回调方法 onMapReady >:

@Override
public void onMapReady(GoogleMap googleMap) {

    map = googleMap;

    updateMapCoordinates();

}

Instead of a MapView use the 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" />

Then init a fragment and get your map with getMapAsync() method:

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

The next implementation is the same as with a MapView - process a callback method onMapReady:

@Override
public void onMapReady(GoogleMap googleMap) {

    map = googleMap;

    updateMapCoordinates();

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文