开发者

How to add multiple marks on MapView - over a hundred

I followed the Hello MapView tutorial on the developer site, and got everything working well. But now I need to expand upon that to add around 150 markers, and my current method crashes my app.

Reason: keyDispatchingTimedOut

My set up is as follows..

Four String arrays with the data for the map, all have (and always will) have the exact same number of indexes and fId[0] == fLatitude[0] == fLongitude[0] == fDetails[0], and so on:

    String[] fId;
    String[] fLatitude;
    String[] fLongitude;
    String[] fDetails;

As of now this is how I am plotting the points on the map. 开发者_C百科 This is obviously not the correct way because the map keeps crashing:

        List<Overlay> mapOverlays = mapView.getOverlays();
    Drawable drawable = this.getResources().getDrawable(R.drawable.androidmarker);
    FriendItemizedOverlay itemizedoverlay = new FriendItemizedOverlay(drawable, mapView.getContext());

    for(int i=0;i<aLatitude.length;i++){

        Double intLon = Double.parseDouble(aLongitude[i]);
        Double intLat = Double.parseDouble(aLatitude[i]);

        GeoPoint point = new GeoPoint((int)(intLat * 1E6), 
                (int)(intLon * 1E6));
        OverlayItem overlayitem = new OverlayItem(point, "Friend ", "Something");

        itemizedoverlay.addOverlay(overlayitem);
        mapOverlays.add(itemizedoverlay);

    }

Let me know in the comments if you need anymore info, thanks.

Logcat:

01-13 18:39:34.732: ERROR/MapActivity(1085): Couldn't get connection factory client 01-13 18:40:14.473: ERROR/ActivityManager(69): ANR in com.example.friendapp (com.example.friendapp/.FriendMaps) 01-13 18:40:14.473: ERROR/ActivityManager(69): Reason: keyDispatchingTimedOut 01-13 18:40:14.473: ERROR/ActivityManager(69): Load: 2.39 / 0.78 / 0.42 01-13 18:40:14.473: ERROR/ActivityManager(69): CPU usage from 6026ms to 0ms ago: 01-13 18:40:14.473: ERROR/ActivityManager(69): 93% 1085/com.example.friendapp: 93% user + 0% kernel / faults: 25 minor 01-13 18:40:14.473: ERROR/ActivityManager(69): 2.6% 69/system_server: 1.8% user + 0.8% kernel / faults: 3 minor 01-13 18:40:14.473: ERROR/ActivityManager(69): 1.1% 875/com.google.process.gapps: 0% user + 1.1% kernel 01-13 18:40:14.473: ERROR/ActivityManager(69): 1.1% 980/com.android.quicksearchbox: 0% user + 1.1% kernel 01-13 18:40:14.473: ERROR/ActivityManager(69): 0.9% 133/com.android.launcher: 0% user + 0.9% kernel 01-13 18:40:14.473: ERROR/ActivityManager(69): 0.1% 40/adbd: 0% user + 0.1% kernel 01-13 18:40:14.473: ERROR/ActivityManager(69): 100% TOTAL: 95% user + 4.1% kernel 01-13 18:40:14.473: ERROR/ActivityManager(69): CPU usage from 2192ms to 2863ms later: 01-13 18:40:14.473: ERROR/ActivityManager(69): 80% 1085/com.example.friendapp: 80% user + 0% kernel / faults: 3 minor 01-13 18:40:14.473: ERROR/ActivityManager(69): 77% 1085/bile.friendapp: 77% user + 0% kernel 01-13 18:40:14.473: ERROR/ActivityManager(69): 16% 69/system_server: 4.8% user + 11% kernel 01-13 18:40:14.473: ERROR/ActivityManager(69): 14% 101/InputDispatcher: 3.2% user + 11% kernel 01-13 18:40:14.473: ERROR/ActivityManager(69): 1.6% 70/HeapWorker: 1.6% user + 0% kernel 01-13 18:40:14.473: ERROR/ActivityManager(69): 0.5% 133/com.android.launcher: 0% user + 0.5% kernel 01-13 18:40:14.473: ERROR/ActivityManager(69): 0.5% 134/HeapWorker: 0% user + 0.5% kernel 01-13 18:40:14.473: ERROR/ActivityManager(69): 0.6% 980/com.android.quicksearchbox: 0% user + 0.6% kernel 01-13 18:40:14.473: ERROR/ActivityManager(69): 1.3% 981/HeapWorker: 0% user + 1.3% kernel 01-13 18:40:14.473: ERROR/ActivityManager(69): 100% TOTAL: 80% user + 19% kernel 01-13 18:40:20.702: ERROR/InputDispatcher(69): channel '406f88b8 com.example.friendapp/com.example.friendapp.FriendMaps (server)' ~ Consumer closed input channel or an error occurred. events=0x8 01-13 18:40:20.712: ERROR/InputDispatcher(69): channel '406f88b8 com.example.friendapp/com.example.friendapp.FriendMaps (server)' ~ Channel is unrecoverably broken and will be disposed!


You are adding the same overlay 150 times to the map. Please only add it once.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜