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 6195511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:28:51+00:00 2026-05-24T03:28:51+00:00

I am using a MapActivity . I take a set of GeoPoints from a

  • 0

I am using a MapActivity. I take a set of GeoPoints from a webserver using JSON and parse it to decoded the Polyline code into geo-points (latitude and longitude) which are then stored in ArrayList<Geopoints>.

These points then get drawn on the MapActivity.

My problem is that it’s not running efficiently since my ArrayList<Geopoints> size is more than 2000. How can I increase the efficiency?

Sample code what i ve done while drawing is

ArrayList'<'Geopoints> mGeoPoints;

Say size of mGeoPoints=2000;

In a class extended by Overlay. some methods of that class how i am writing is.

public boolean draw(Canvas canvas, MapView mapView, boolean shadow,long when) {
       super.draw(canvas, mapView, shadow, when);
        drawPath(mapView, canvas);
        return true;
    }

public void drawPath(MapView mv, Canvas canvas) {
        int x1 = -1, y1 = -1, x2 = -1, y2 = -1;
        Paint paint = new Paint();
        paint.setColor(Color.GREEN);
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(3);
                for (int i = 0; i < mGeoPoints.size(); i++) {
            Point point = new Point();
            mv.getProjection().toPixels(mGeoPoints.get(i), point);
            x2 = point.x;
            y2 = point.y;
            if (i > 0) {
                canvas.drawLine(x1, y1, x2, y2, paint);
            }
            x1 = x2;
            y1 = y2;
        }
    }

This code is working fine. its drawing correctly on the map. When i zoom the map or move the map application is hanging.

I have set the zoom level to 16 mapController.setZoom(16);; can any one help me? To make it run fast even when user zoom it by hand.

  • 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-24T03:28:52+00:00Added an answer on May 24, 2026 at 3:28 am

    The first 2 things that really jump out at me are i < mGeoPoints.size(); and Point point = new Point();

    You can optimise both of these right there by storing the length of the array in a local variable and much ore importantly reuse the variable point. Creating a new instance 2000 times per draw loop will hammer your phone into tiny pieces!

    Also make sure your getProjection(...) method reuses the point passed in. As long as your point values are reset properly you can use something like this:

    Point point = new Point();
    
    for (int i = 0; i < mGeoPoints.size(); i++) 
    {
        mv.getProjection().toPixels(mGeoPoints.get(i), point);
        x2 = point.x;
        y2 = point.y;
        if (i > 0) 
        {
            canvas.drawLine(x1, y1, x2, y2, paint);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to launch a MapActivity from Activity using intent. Following is how
I have a mapview class which extends MapActivity. The code i'm using follows the
Using JDeveloper , I started developing a set of web pages for a project
Using preview 4 of ASP.NET MVC Code like: <%= Html.CheckBox( myCheckBox, Click Here, True,
I've got an app using MapActivity.onCreate() to initialize the map and show it on
Here is my code to display the google map in my android emulator using
i am using MapActivity in my application to show map and for that i
Is there any solution for using the a MapView (and thus the MapActivity )
I have added multiple ovals on map view by using below code but I
I am using the following code to get my current location. But the problem

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.