当我的谷歌地图视图活动重新获得焦点时出现问题(地图窗口下部有黑色区域)

发布于 2024-10-04 01:54:45 字数 551 浏览 4 评论 0原文

我的应用程序有问题,它有很多活动,其中两个有谷歌地图视图。我的 A 活动有完整的地图视图,我的 B 活动有小地图视图。好的,当我处于 B 活动并有时按返回键直到返回 A 活动时,我的 A 活动的地图显示错误,窗口下部有一个黑色区域。只有当我从 B 活动按回时才会发生这种情况。

因此,我需要实现/覆盖 A 的 onResume() 方法来重新启动从 SRATCH 重新绘制所有内容的活动...喜欢再次执行 ONCREATE 方法,但我认为我不能再次调用它...或者我能?

我必须输入哪些代码才能从头开始重新绘制所有窗口?

我尝试了所有这些:

-mapView.requestLayout() -->它工作了一点,重新绘制地图,但通过缩放并显示 B 活动上显示的最后一张地图......没有意义:我不想要那样。不同的地图,不一定要显示相同的坐标和缩放比例,各有各的。

-mapView.invalidate() -->不起作用

-mapView.postInvaldiate() -->不起作用

i have a problem with my app, it haves a lot of activitys, two of them haves googlemap views. My A activity haves a full mapview and my B activity haves a small map view. OK, when i am on the B activity and press back key somethimes until i return to my A activity, the map of my A activity shows with errors, with a black zone in the down part of the window. THis only happens when i press back from the B activity.

Because this, i need to implement/override onResume() method of A to RESTART THE ACTIVITY TO REPAINT ALL FROM SRATCH.... LIKE TO DO AGAIN ONCREATE METHOD, but i think i can't call it again... or i can?

wich code i have to put to repaint all the window from scratch ?

i tryed with all this:

-mapView.requestLayout() --> it works a little, repaints the map but with the zoom and showing the last map showed on B activity... no sense :S i dont want that. Are different maps, not have to show the same coordinates and zoom, each one have his own.

-mapView.invalidate() --> doesn't works

-mapView.postInvaldiate() --> doesn't works

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

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

发布评论

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

评论(1

天煞孤星 2024-10-11 01:54:45

不建议在同一进程中运行多个地图 (MapView)。通常,使用默认配置,所有活动(包括 MapActivities)都在同一进程中运行。

根据 api 文档,位于此处
http://code .google.com/android/add-ons/google-apis/reference/com/google/android/maps/MapActivity.html

每个进程仅支持一个 MapActivity。同时运行的多个 MapActivities 可能会以意想不到的方式产生干扰。

我在同一进程中使用多个 MapView 时遇到的问题:

  • 尽管看起来有 2 个
    应用程序中的不同地图,变化
    第一张地图(例如:将其移动到
    特定位置,切换卫星
    视图)也反映在
    第二张地图,好像是一样的
    地图。
  • 有时,地图图块不是
    正确加载。部分
    地图,或者完整的地图仍然存在
    空的。
  • 在 Logcat 中,记录了 apache http 连接池错误(源自 TilesProvider)

此处记录了一个缺陷:http://code.google.com/p/android/issues/detail?id=3756

解决方案/解决方法是将地图托管在不同的进程中:

<activity android:name=".MapView1" android:process=":MapView1">
<activity android:name=".MapView2" android:process=":MapView2">

Having multiple maps (MapViews) running in the same process is not adviced. Typically, using the default configuration, all Activities (including MapActivities) run within the same process.

According to the api docs, located here
http://code.google.com/android/add-ons/google-apis/reference/com/google/android/maps/MapActivity.html

Only one MapActivity is supported per process. Multiple MapActivities running simultaneously are likely to interfere in unexpected and undesired ways.

Issues I encountered with multiple MapViews within the same process :

  • Although it appears that there are 2
    different maps in the app, changes in
    the first map (ex: moving it to a
    certain position, toggling sattelite
    view) also got reflected in the
    second map, as if it was the same
    map.
  • On occasion, map tiles were not
    getting loaded properly. Portions of
    the map, or the complete map remained
    empty.
  • In Logcat, apache http connection pool errors were logged (originating from the TilesProvider)

There is a defect logged here : http://code.google.com/p/android/issues/detail?id=3756

A solution / workaround is to host your maps in different processes :

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