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();
}