Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7010005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:56:05+00:00 2026-05-27T21:56:05+00:00

I’ve been successful at adding map pins to my map overlay but it loads

  • 0

I’ve been successful at adding map pins to my map overlay but it loads slow and moving around the map is sluggish. I am thinking it is when it is downloading the map pins from the server. The pins are only about 20-30 kb in size, but at times are may be 25 pins to add. I have already tried to add the pins in the background but it will break the app. What can I do to add the pins in the background without affecting performance?

I get the location from map when the user touches the map and executes this ASYNC task.

    private class mapStations extends AsyncTask<Void, Void, JSONObject> {

    @Override
    protected JSONObject doInBackground(Void... arg0) {

        JSONObject obj = null;
        try {
            obj = new JSONObject(API.nearByStations(pxLat, pxLng, 0));

        } catch (JSONException e) {
            e.printStackTrace();
        }

        return obj;
    }

    @Override
    protected void onPostExecute(JSONObject details) {
        String tag = "mapStations";
        JSONArray stations;
        Drawable d = null;
        try {
            mapOverlays = mapView.getOverlays();
            mapOverlays.clear();
            stations = details.getJSONArray("stations");

            for (int j = 0; j < stations.length(); j++) {
                JSONObject jsonObject = stations.getJSONObject(j);
                Log.i(tag, "url: " + jsonObject.getString("logo"));
                try {

                    Bitmap staticImage = BitmapFactory
                            .decodeStream((InputStream) new URL(jsonObject.getString("logo"))
                                    .getContent());
                    d = new BitmapDrawable(staticImage);

                } catch (MalformedURLException e) {
                    Log.e(tag, e.toString());
                    e.printStackTrace();
                } catch (IOException e) {
                    Log.e(tag, e.toString());
                    e.printStackTrace();
                }
                add(jsonObject.getDouble("lat"),
                        jsonObject.getDouble("lng"), d);
            }

        } catch (JSONException e) {
            e.printStackTrace();
        }

    }
}

public void add(double lat, double lng, Drawable d) {

    mapOverlays = mapView.getOverlays();
    if(d.equals(null)){
        Log.i(tag, "d was null");
        d = this.getResources().getDrawable(R.drawable.androidmarker);
    }

    itemizedOverlay = new MapsOverlay(d);

    GeoPoint point = new GeoPoint((int) (lat * 1e6), (int) (lng * 1e6));
    OverlayItem overlayitem = new OverlayItem(point, "", "");

    itemizedOverlay.addOverlay(overlayitem);
    mapOverlays.add(itemizedOverlay);
}

This is the logcat from adding the points in the doinbackground. It doesn’t happen every time but it does happen. I can’t seem to reproduce when it happens either. Sometime it happens when I zoom out, sometimes it happens when I move around the map. I had similar question about this here Android MapView JSON Array Adding Array of points but I ended up moving it to the post execute. Like I mentioned before it takes awhile to load the pins. I am kind of at a loss write now. I have been working on this all day.

    [12-23 13:46:27.246: E/AndroidRuntime(1359): Uncaught handler: thread main exiting due to uncaught exception
12-23 13:46:27.286: E/AndroidRuntime(1359): java.util.ConcurrentModificationException
12-23 13:46:27.286: E/AndroidRuntime(1359):     at java.util.AbstractList$SimpleListIterator.next(AbstractList.java:64)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at com.google.android.maps.OverlayBundle.draw(OverlayBundle.java:41)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at com.google.android.maps.MapView.onDraw(MapView.java:476)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at android.view.View.draw(View.java:6535)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at android.view.View.draw(View.java:6538)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at android.widget.FrameLayout.draw(FrameLayout.java:352)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at android.view.View.draw(View.java:6538)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at android.widget.FrameLayout.draw(FrameLayout.java:352)][1]
12-23 13:46:27.286: E/AndroidRuntime(1359):     at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at android.view.View.draw(View.java:6538)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at android.widget.FrameLayout.draw(FrameLayout.java:352)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1830)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at android.view.ViewRoot.draw(ViewRoot.java:1349)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at android.view.ViewRoot.performTraversals(ViewRoot.java:1114)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1633)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at android.os.Handler.dispatchMessage(Handler.java:99)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at android.os.Looper.loop(Looper.java:123)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at android.app.ActivityThread.main(ActivityThread.java:4363)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at java.lang.reflect.Method.invokeNative(Native Method)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at java.lang.reflect.Method.invoke(Method.java:521)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
12-23 13:46:27.286: E/AndroidRuntime(1359):     at dalvik.system.NativeStart.main(Native Method)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:56:06+00:00Added an answer on May 27, 2026 at 9:56 pm

    In order to prevent the user for inadvertently editing the list while it is already being edited. I decided to place dialog in the onPreExecute() while the pins are being loaded. This has prevented the user from touching the map while new pins are being added. Until I can find time to come up with a better idea on how to prevent this from happening this will have to do.

    I clear the overlays from the map before I start adding new pins, this is completed during onPreExecute(). On the onPostExecute() I dismiss the dialog and invalidate() the map. This will draw the new map pins on the map after adding them to the list.

    @Override
        protected void onPreExecute() {
            Log.i(tag, "AsyncTask Started");
            dialog.show();
            mapOverlays = mapView.getOverlays();
            mapOverlays.clear();
        }
    
    @Override
        protected void onPostExecute(Void args) {
            mapView.invalidate();
            dialog.dismiss();
            Log.i(tag, "AsyncTask Post");
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I want to construct a data frame in an Rcpp function, but when I
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.