清除缓存或首页加载后,Google地图标记未显示,但在刷新时显示

时间:2018-04-11 16:44:33

标签: android refresh google-maps-markers markerclusterer clear-cache

我已在Android中使用我的标记开发了googleMap,但它们只会在刷新或执行过滤后显示,并且在第一次运行或清除缓存后不会显示。

    protected void refreshMap()
{
    final boolean useClusters = NumericUtil.parseBool(getObjectModel("useClusters"));
    markerArray = new ArrayList();
    markersMap = new Hashtable();
    poiMarkersMap = new Hashtable();
    locationMapper = new ArrayList();
    IDictionary attachments = new Hashtable();

    safeInvokeSync(new Runnable() {
        @Override
        public void run()
        {
            googleMap.clear();
            if (mClusterManager != null)
                mClusterManager.clearItems();
            //configOfflineMaps();
        }
    });
         safeInvokeAsync(new Runnable() {
                @Override
                public void run()
                {
                    if (useClusters && valuesCount > 2)
                    {
                        if (mClusterManager == null)
                        {
                            mClusterManager = new ClusterManager<>(getContext(), googleMap);
                            mClusterManager.setRenderer(createMarkerRenderer());
                            googleMap.setOnCameraChangeListener(mClusterManager);
                        }

                        ClusterMarker clusterMarker = new ClusterMarker(position, marker.getTitle(), marker.getSnippet(), marker.getIcon(), entry);
                        mClusterManager.addItem(clusterMarker);
                        mClusterManager.cluster();
                    }
                    else
                    {
                        Marker newMarker = googleMap.addMarker(marker);
                        newMarker.setDraggable(checkPermissionsValue(Permissions.Update));
                        markersMap.put(newMarker.getId(), entry);
                        markerArray.add(newMarker);
                    }
                }
            });
        }

}

0 个答案:

没有答案