Hello developers,

Sorry for the inconvenience .. but am stuck up here for quite a
while !!!


We have developed a GPS based app in which it 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......

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......


Kindly let us know if any difficulty in understanding the Q , i shall
try to make simpler.

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 Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to