Efficient Map Overlays in Android Google Map

后端 未结 5 1319
北恋
北恋 2020-12-04 07:50

I want to do the following and am kind of stuck on these for a few days:

  1. I was trying to draw polylines (I have encoded polylines, but have

5条回答
  •  伪装坚强ぢ
    2020-12-04 08:31

    For #2, I don't think you solved anything there. Your hard-to-read code is showing how to put markers on overlay and then, how to add that overlay to the map. That's exactly how I do it. I have map with around 300 hotels and it takes around 5 seconds for Android on my Nexus One to create markers. The whole thing is running inside thread and I guess I will have to do some sort of progress bar to let user know what's going on.

    I am working on app that already exists on iPhone and it seems iPhone doesn't have any issues to almost instantaneously draw these 300+ markers. I'll have hard time to explain existence of progress bar to my bosses.

    If anybody have idea how to optimize this process... I will be grateful.

    Here is my code:

        ...
            for (int m = 0; m < ArrList.size(); m++) {
                tName = ArrList.get(m).get("name").toString();
                tId = ArrList.get(m).get("id").toString();
                tLat = ArrList.get(m).get("lat").toString();;
                tLng = ArrList.get(m).get("lng").toString();;
                try {
                    lat = Double.parseDouble(tLat);
                    lng = Double.parseDouble(tLng);
                    p1 = new GeoPoint(
                            (int) (lat * 1E6), 
                            (int) (lng * 1E6));
                    OverlayItem overlayitem = new OverlayItem(p1, tName, tId);
                    itemizedoverlay.addOverlay(overlayitem);
                } catch (NumberFormatException e) {
                    Log.d(TAG, "NumberFormatException" + e);    
                }
            } 
    

    I know I could save some time by avoiding this String > Double conversion, but I don't feel that would give me significant saving.. or it would?

提交回复
热议问题