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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:02:03+00:00 2026-05-24T00:02:03+00:00

I have a MapView and I’m overlaying 1,700 points onto it, each with the

  • 0

I have a MapView and I’m overlaying 1,700 points onto it, each with the same drawable but with different information. I’m currently using Itemized Overlay to add all the overlays then populate once fished. This works, but the performance is slow. Changing zoom level and focus is jumpy. Now, would it be any better to use ArrayItemizedOverlay since it’s the same drawable, or would the map be just as slow?

import java.util.ArrayList;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.app.Activity;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.MapView;
import com.google.android.maps.OverlayItem; 

public class Points extends ItemizedOverlay <OverlayItem> {
    Context mContext; 
    private ArrayList mOverlays = new ArrayList();

    String newLine = String.format("%n");

    public Points(Drawable defaultMarker) {
        super(boundCenterBottom(defaultMarker));
        // TODO Auto-generated constructor stub
    }

    @Override
    protected OverlayItem createItem(int i) {
        return (OverlayItem) mOverlays.get(i);
    }

    @Override
    public int size() {
        return mOverlays.size();
    }

    @Override
    public void draw(Canvas canvas,
            MapView mapView,
            boolean shadow) {
        if (!shadow)
            super.draw(canvas, mapView, shadow);
    }

    public void addOverlay(OverlayItem overlay) {   
        mOverlays.add(overlay);   
    }

    public void populateNow(){
        setLastFocusedIndex(-1);
        populate();
    }

    public Points(Drawable defaultMarker, Context context) {  
        super(boundCenterBottom(defaultMarker)); 
        mContext = context;
    }

    @Override
    protected boolean onTap(int index) { 
        Intent intent = new Intent();
        OverlayItem item = (OverlayItem) mOverlays.get(index); 
        AlertDialog.Builder dialog1 = new AlertDialog.Builder(mContext);  
        dialog1.setTitle(item.getTitle());  
        String info = item.getSnippet();
        String delims = "[$]";
        String [] tokens = info.split(delims);
        String info1 = tokens [0];
        String info2 = tokens[1];
        String delims2 = "[!]";
        String [] tokens2 = info1.split(delims2);
        double lat = Double.parseDouble(tokens2[0]);
        double lon = Double.parseDouble(tokens2[1]);
        final String location = tokens2[0]+","+tokens2[1];

        dialog1.setMessage(info2);

        dialog1.setPositiveButton("Navigate", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                Nav(location);
            }
        });
        dialog1.setNegativeButton("Directions", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                Direction(location);
            }
        }) ;

        dialog1.show(); 
        return true;
    }

    public void Nav(String location) {
        Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("google.navigation:q=" + location)); 
        mContext.startActivity(i);
    }

    public void Direction(String location) {
        Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?daddr=" + location)); 
        mContext.startActivity(i);
    }
}

How I’m adding items:

mapOverlays = mapView.getOverlays();
Drawable drawable = this.getResources().getDrawable(R.drawable.plug);
itemizedoverlay = new Points(drawable, this);

while (...) {
    point = new GeoPoint((int) (lat * 1000000), (int) (lon * 1000000));
    overlayitem = new OverlayItem(point, Station_Name, comb);
    itemizedoverlay.addOverlay(overlayitem);
}
  • 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-24T00:02:04+00:00Added an answer on May 24, 2026 at 12:02 am

    This is not a solution, but rather a workaround while waiting for the perfect solution.

    I had the same issue and created multiple overlays.

    6 overlays with 99 points are really faster than 1 overlay with 600 points.

    (15 sec loading time Vs 1 second)

            for (int i = 0; i < 99; i++) {
                webcamCursor.moveToPosition(i);
                float lat = Float.valueOf(webcamCursor.getString(webcamCursor
                        .getColumnIndex("Lat")));
                float lon = Float.valueOf(webcamCursor.getString(webcamCursor
                        .getColumnIndex("Lon")));
                GeoPoint gp = new GeoPoint((int) (lat / 10), (int) (lon / 10));
                myOverlay1.addPoint(gp);
            }
            for (int i = 100; i < 199; i++) {
                webcamCursor.moveToPosition(i);
                float lat = Float.valueOf(webcamCursor.getString(webcamCursor
                        .getColumnIndex("Lat")));
                float lon = Float.valueOf(webcamCursor.getString(webcamCursor
                        .getColumnIndex("Lon")));
                GeoPoint gp = new GeoPoint((int) (lat / 10), (int) (lon / 10));
                myOverlay2.addPoint(gp);
            }
            for (int i = 200; i < 299; i++) {
                webcamCursor.moveToPosition(i);
                float lat = Float.valueOf(webcamCursor.getString(webcamCursor
                        .getColumnIndex("Lat")));
                float lon = Float.valueOf(webcamCursor.getString(webcamCursor
                        .getColumnIndex("Lon")));
                GeoPoint gp = new GeoPoint((int) (lat / 10), (int) (lon / 10));
                myOverlay3.addPoint(gp);
            }
            for (int i = 300; i < 399; i++) {
                webcamCursor.moveToPosition(i);
                float lat = Float.valueOf(webcamCursor.getString(webcamCursor
                        .getColumnIndex("Lat")));
                float lon = Float.valueOf(webcamCursor.getString(webcamCursor
                        .getColumnIndex("Lon")));
                GeoPoint gp = new GeoPoint((int) (lat / 10), (int) (lon / 10));
                myOverlay4.addPoint(gp);
            }
            for (int i = 400; i < 499; i++) {
                webcamCursor.moveToPosition(i);
                float lat = Float.valueOf(webcamCursor.getString(webcamCursor
                        .getColumnIndex("Lat")));
                float lon = Float.valueOf(webcamCursor.getString(webcamCursor
                        .getColumnIndex("Lon")));
                GeoPoint gp = new GeoPoint((int) (lat / 10), (int) (lon / 10));
                myOverlay5.addPoint(gp);
            }
            for (int i = 500; i < webcamCursor.getCount(); i++) {
                webcamCursor.moveToPosition(i);
                float lat = Float.valueOf(webcamCursor.getString(webcamCursor
                        .getColumnIndex("Lat")));
                float lon = Float.valueOf(webcamCursor.getString(webcamCursor
                        .getColumnIndex("Lon")));
                GeoPoint gp = new GeoPoint((int) (lat / 10), (int) (lon / 10));
                myOverlay6.addPoint(gp);
            }
            System.out.println("**TIME**" + (System.currentTimeMillis() - t));
    
            mMap.getOverlays().add(myOverlay1);
            mMap.getOverlays().add(myOverlay2);
            mMap.getOverlays().add(myOverlay3);
            mMap.getOverlays().add(myOverlay4);
            mMap.getOverlays().add(myOverlay5);
            mMap.getOverlays().add(myOverlay6);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have A MapView with Multiple annotations. But I need to put different images
I have a MapView in which I am drawing buildings on using geopoints. Currently,
HI, I have a Mapview with some marker points + a marker for current
I have a strange problem using a MapView in Android. It works fine until
I have a MapView onto which I put some overlays (MKPolygon). I have to
I have a mapview where i update my currentlocation with CoreLocation, but I also
I have a mapview in my appn. I show some points on the map
I have a mapview class which extends MapActivity. The code i'm using follows the
I have a mapview , with itemizedoverlay , like on Android developers example. But
I have a mapview and i wish to display a ContextMenu when longclick but

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.