googlemaps/android-maps-utils

KMZ loaded really slow

z3r01993 opened this issue · 2 comments

Hello I'm having a problem on some kind of android phones and tablets (with 3 GB ram and Android 13).
When I load 8 KMZ that are around 3.5 MB in Total, Google Map freeze and become black for around 11 seconds on tablet and around 31 seconds on phone.

I'm loading the KMZ this way:

private void loadKmz(){
        try {
            KmlLayer kmz1 = new KmlLayer(mGoogleMap, R.raw.centri_abitati_1, requireContext());
            KmlLayer kmz2  = new KmlLayer(mGoogleMap, R.raw.centri_abitati_2, requireContext());
            KmlLayer kmz3  = new KmlLayer(mGoogleMap, R.raw.confini_comuni_1, requireContext());
            KmlLayer kmz4  = new KmlLayer(mGoogleMap, R.raw.confini_comuni_2, requireContext());
            KmlLayer kmz5  = new KmlLayer(mGoogleMap, R.raw.viabilita_1, requireContext());
            KmlLayer kmz6  = new KmlLayer(mGoogleMap, R.raw.viabilita_2, requireContext());
            KmlLayer kmz7  = new KmlLayer(mGoogleMap, R.raw.viabilita_3, requireContext());
            KmlLayer kmz8  = new KmlLayer(mGoogleMap, R.raw.viabilita_4, requireContext());
            kmz1.addLayerToMap();
            kmz2.addLayerToMap();
            kmz3.addLayerToMap();
            kmz4.addLayerToMap();
            kmz5.addLayerToMap();
            kmz6.addLayerToMap();
            kmz7.addLayerToMap();
            kmz8.addLayerToMap();
        } catch (XmlPullParserException xppE) {
            Logger.onException(TAG, xppE);
        } catch (IOException ioE) {
            Logger.onException(TAG, ioE);
        }
    }

What could be the problem?

Thank you so much! (:

If you would like to upvote the priority of this issue, please comment below or react with 👍 so we can see what is popular when we triage.

@z3r01993 Thank you for opening this issue. 🙏
Please check out these other resources that might help you get to a resolution in the meantime:

This is an automated message, feel free to ignore.

Perhaps it's the multiple calls to requireContext(). Try following the pattern in the demo activity to pass context. Feel free to re-open if it's still happening.