0

Web サービスからデータを取得し、そのデータに基づいてオーバーレイ アイテムを表示できるカスタム マップアプリケーションを開発しています。これが問題です。アプリを実行するとマップとオーバーレイが正しく表示されますが、ズームまたはタップしようとすると、パフォーマンスが非常に遅くなります。そのため、ここでいくつかのパフォーマンスの問題が発生しています。実際には、50 のオーバーレイしかない多数のデータが含まれているわけではありません。

アイテムオーバーレイの追加に何か問題があるのではないかと疑っています。確認して助けてください。

コード:

private void showWhaleDophinSightingsToMap() {
    mapOverlays = mapView.getOverlays();
    progressDialog.dismiss();
    // Show overlay for whale sightings
    Log.i(TAG, "whaleWatchingInfoList >>>>>> " + whaleWatchingInfoList);
    Log.i(TAG, "whaleWatchingInfoList >>>>>> "+ whaleWatchingInfoList.size());
    if(whaleWatchingInfoList != null && whaleWatchingInfoList.size() > 0) {
            drawable = getResources().getDrawable(R.drawable.north);            
            customItemizedOverlay = new CustomItemizedOverlay<CustomOverlayItem>(drawable, mapView);
            for(int i = 0; i < whaleWatchingInfoList.size(); i++) {
                    if(i == 0) {
                            MapController mc = mapView.getController();
                            mc.setZoom(7);
                            // Zoom Level 
                            mapView.getController().setCenter(new GeoPoint((int)(whaleWatchingInfoList.get(i).getLatitude() * 1E6),
                            (int)(whaleWatchingInfoList.get(i).getLongtitude() * 1E6)));
                    }else {
                            geoPoint = new GeoPoint((int)(whaleWatchingInfoList.get(i).getLatitude() * 1E6),
                            (int)(whaleWatchingInfoList.get(i).getLongtitude() * 1E6));
                            CustomOverlayItem customOverlayItem = new CustomOverlayItem(geoPoint, whaleWatchingInfoList.get(i).getName(), whaleWatchingInfoList.get(i).getDescription(), whaleWatchingInfoList.get(i).getImageUrl(), whaleWatchingInfoList.get(i).getAtdwProductUrl());
                            customItemizedOverlay.addOverlay(customOverlayItem);    
                            mapOverlays.add(customItemizedOverlay);
                    }
            }
    }
    mapView.postInvalidate();   
}
4

1 に答える 1

0

答えられるかわかりません。私の場合、マップビューを取得するときに2行を追加しました。これにより、マップの移動やズームのパフォーマンスが大幅に向上します。そしてそれは私の問題を解決します。

mapView.setAlwaysDrawnWithCacheEnabled(true);
mapView.setPersistentDrawingCache(MapView.PERSISTENT_ALL_CACHES);

お役に立てば幸いです。

于 2013-01-09T08:26:06.573 に答える