Hi developers,

I've developed a GPS app in which i record the user routes and show it
on the map.......but Panning around on the map when reviewing my route
is painfully slow, it takes at least 4 or 5 seconds for the map to
respond the finger swipes......

I've overridden the onDraw() method and drawing the lines to show the
routes whenever we zoom on the map, the lat-long is again drawn by
calling onDraw()(Overridden) method , which has the geopoints with lat-
lon values, and thus it becomes very slower process to display the
map .. is there any better way to do this so that panning becomes
faster as in "MyTracks"

Following is the code to draw the routes on map...........please look
into it and guide me how can i make it more efficient so that the
panning and zooming works well......



thank u, regards Sheik Ahmed

class PathOverlay extends Overlay{
  public PathOverlay() {
        // TODO Auto-generated constructor stub
        geopoints=new ArrayList<GeoPoint>();
        c.moveToFirst();
        for (int i = 0; i <c.getCount() ; i++){

            if(c.getDouble(c.getColumnIndex("latitude")) != 0.0 ||
                    c.getDouble(c.getColumnIndex("longitude"))!=0.0) {

 
geopoints.add(getPoint(c.getDouble(c.getColumnIndex("latitude"))
                        ,
c.getDouble(c.getColumnIndex("longitude"))));
 
gps_status.add(Boolean.parseBoolean(c.getString(c.getColumnIndex("gps") )));
                avgeSpeed_points.add(c.getFloat(9));
            }
            c.moveToNext();


        }

    }
    private GeoPoint getPoint(double lat, double lon) {
        return(new GeoPoint((int)(lat*1000000.0),(int)
(lon*1000000.0)));
    }

    @Override
    public void draw(Canvas canvas, MapView mapView, boolean shadow) {

    //  super.draw(canvas, mapView, shadow);
        mapView.getDrawingCache();

        Paint paint_Line=new Paint();
        //paint_Line.setColor(Color.RED);
        paint_Line.setARGB(255, 255, 0, 0);
        paint_Line.setStrokeWidth(3);
        paint_Line.setDither(true);
        paint_Line.setStyle(Style.FILL);
        paint_Line.setAntiAlias(true);
        paint_Line.setStrokeJoin(Paint.Join.ROUND);
        paint_Line.setStrokeCap(Paint.Cap.ROUND);



        mapView.postInvalidateDelayed(6000);


        for(int i=0;i<geopoints.size()-1;i++) {

            Point p1=new Point();
            Point p2=new Point();

            if((geopoints.get(i).getLatitudeE6()!=geopoints.get(i
+1).getLatitudeE6())
                    && (geopoints.get(i).getLongitudeE6()!
=geopoints.get(i+1).getLongitudeE6())
                    && gps_status.get(i+1)){
            paint_Line.setColor(Color.BLUE);
            mapView.getProjection().toPixels(geopoints.get(i), p1);
            mapView.getProjection().toPixels(geopoints.get(i+1),p2);
            canvas.drawLine(p1.x,p1.y,p2.x,p2.y,paint_Line);
           }

            mapView.getProjection().toPixels(geopoints.get(i),p1);
            if(i==0){
                canvas.drawBitmap(start, p1.x-2, p1.y-start.getHeight()
+2, null);
            }
            if (i+1==geopoints.size()-1) {
                canvas.drawBitmap(finish, p1.x-2, p1.y-
finish.getHeight()+2, null);
            }
        }






    }

}

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to