Re: [android-developers] Connecting 4 Geopoints

2011-02-14 Thread TreKing
On Sun, Feb 6, 2011 at 11:49 PM, Naveen HS  wrote:

> Now i am trying to animate the line while drawing between 2 Geopoints, i
> just want to show them some kind of animation while drawing line .. is it
> possible to do ?? or i can call some delay function ??


Create some kind of "Animator" class that runs a timer triggering an update
however often you need to animate. All it does it store the current sequence
of points that should be shown. As the timer goes off, it updates the
sequence and triggers a redraw, making the line drawing animate.

-
TreKing  - Chicago
transit tracking app for Android-powered devices

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

[android-developers] Connecting 4 Geopoints

2011-02-11 Thread Naveen
Hello All,


I am having 4 static Geopoints, I am able to mark them on the Map and
also i am able to draw line between them.

Now i am trying to animate the line while drawing between 2 Geopoints,
i just want to show them some kind of animation while drawing line ..
is it possible to do ?? or i can call some delay function ??

Please help me with this ..

My function

public class HelloMapView extends MapActivity {
/** Called when the activity is first created. */
LinearLayout linearLayout;
MapView mapView;
MapController mc;
GeoPoint p,p1,p2,p3;

class MapOverlay extends com.google.android.maps.Overlay
{
@Override
public boolean draw(Canvas canvas, MapView mapView,
boolean shadow, long when)
{
super.draw(canvas, mapView, shadow);

//---translate the GeoPoint to screen pixels---
Point screenPts = new Point();
mapView.getProjection().toPixels(p, screenPts);

//---add the marker---
Bitmap bmp = BitmapFactory.decodeResource(
getResources(), R.drawable.a);
canvas.drawBitmap(bmp, screenPts.x, screenPts.y-35,
null);

//Coordinates 2

  //---translate the GeoPoint to screen pixels---
Point screenPts1 = new Point();
mapView.getProjection().toPixels(p1, screenPts1);

//---add the marker---
Bitmap bmp1 = BitmapFactory.decodeResource(
getResources(), R.drawable.b);
canvas.drawBitmap(bmp1, screenPts1.x, screenPts1.y-35,
null);

//Coordinates 3

   //---translate the GeoPoint to screen pixels---
Point screenPts2 = new Point();
mapView.getProjection().toPixels(p2, screenPts2);

//---add the marker---
Bitmap bmp2 = BitmapFactory.decodeResource(
getResources(), R.drawable.c);
canvas.drawBitmap(bmp2, screenPts2.x, screenPts2.y-35,
null);


//Coordinates 4

//---translate the GeoPoint to screen pixels---
 Point screenPts3 = new Point();
 mapView.getProjection().toPixels(p3, screenPts3);

 //---add the marker---
 Bitmap bmp3 = BitmapFactory.decodeResource(
 getResources(), R.drawable.dgreen);
 canvas.drawBitmap(bmp3, screenPts3.x, screenPts3.y-35,
null);



//--- Start--//

Paint mPaint = new Paint();
mPaint.setStyle(Style.FILL);
mPaint.setStrokeWidth(3);
mPaint.setColor(Color.BLUE);
mPaint.setAntiAlias(true);
//canvas.drawPath(path,mPaint);
super.draw(canvas, mapView, shadow);
canvas.drawLine(screenPts.x, screenPts.y, screenPts1.x,
screenPts1.y, mPaint);
canvas.drawLine(screenPts1.x, screenPts1.y, screenPts2.x,
screenPts2.y, mPaint);
canvas.drawLine(screenPts2.x, screenPts2.y, screenPts3.x,
screenPts3.y, mPaint);
return true;
}
}


@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

mapView = (MapView) findViewById(R.id.mapview);

mapView.setBuiltInZoomControls(true);

mapView = (MapView) findViewById(R.id.mapview);



mapView.displayZoomControls(true);
mc = mapView.getController();
String coordinates[] = {"12.958998", "77.658998"};
double lat = Double.parseDouble(coordinates[0]);
double lng = Double.parseDouble(coordinates[1]);

p = new GeoPoint(
(int) (lat * 1E6),
(int) (lng * 1E6));


String coordinates1[] = {"12.95967","77.64918"};
double lat1 = Double.parseDouble(coordinates1[0]);
double lng1 = Double.parseDouble(coordinates1[1]);

p1 = new GeoPoint(
(int) (lat1 * 1E6),
(int) (lng1 * 1E6));

//For geopoint point 3

String coordinates2[] = {"12.96052","77.64171"};
double lat2 = Double.parseDouble(coordinates2[0]);
double lng2 = Double.parseDouble(coordinates2[1]);

p2 = new GeoPoint(
(int) (lat2 * 1E6),
(int) (lng2 * 1E6));

//For geopoint point 4
String coordinates3[] = {"12.96721","77.64141"};
double lat3 = Double.parseDouble(coordinates3[0]);
double lng3 = Double.parseDouble(coordinates3[1]);

p3 = new GeoPoint(
(int) (lat3 * 1E6),
(int) (lng3 * 1E6));



mc.animateTo(p);
mc.animateTo(p1);
mc.animateTo(p2);
mc.animateTo(p3);
mc.setZoom(16);

  //---Add a location marker---
MapOverlay mapOverlay = new MapOverlay();
List listOfOverlays = mapView.getOverlays();
listOfOverlays.clear();
listOfOverlays.add(mapOverlay);

mapView.invalidate();


 

[android-developers] Connecting 4 Geopoints

2011-02-11 Thread Naveen HS
Hello All,


I am having 4 static Geopoints, I am able to mark them on the Map and also i
am able to draw line between them.

Now i am trying to animate the line while drawing between 2 Geopoints, i
just want to show them some kind of animation while drawing line .. is it
possible to do ?? or i can call some delay function ??

Please help me with this ..

My function

public class HelloMapView extends MapActivity {
/** Called when the activity is first created. */
LinearLayout linearLayout;
MapView mapView;
MapController mc;
GeoPoint p,p1,p2,p3;

class MapOverlay extends com.google.android.maps.Overlay
{
@Override
public boolean draw(Canvas canvas, MapView mapView,
boolean shadow, long when)
{
super.draw(canvas, mapView, shadow);

//---translate the GeoPoint to screen pixels---
Point screenPts = new Point();
mapView.getProjection().toPixels(p, screenPts);

//---add the marker---
Bitmap bmp = BitmapFactory.decodeResource(
getResources(), R.drawable.a);
canvas.drawBitmap(bmp, screenPts.x, screenPts.y-35, null);

//Coordinates 2

  //---translate the GeoPoint to screen pixels---
Point screenPts1 = new Point();
mapView.getProjection().toPixels(p1, screenPts1);

//---add the marker---
Bitmap bmp1 = BitmapFactory.decodeResource(
getResources(), R.drawable.b);
canvas.drawBitmap(bmp1, screenPts1.x, screenPts1.y-35, null);

//Coordinates 3

   //---translate the GeoPoint to screen pixels---
Point screenPts2 = new Point();
mapView.getProjection().toPixels(p2, screenPts2);

//---add the marker---
Bitmap bmp2 = BitmapFactory.decodeResource(
getResources(), R.drawable.c);
canvas.drawBitmap(bmp2, screenPts2.x, screenPts2.y-35, null);


//Coordinates 4

//---translate the GeoPoint to screen pixels---
 Point screenPts3 = new Point();
 mapView.getProjection().toPixels(p3, screenPts3);

 //---add the marker---
 Bitmap bmp3 = BitmapFactory.decodeResource(
 getResources(), R.drawable.dgreen);
 canvas.drawBitmap(bmp3, screenPts3.x, screenPts3.y-35, null);



//--- Start--//

Paint mPaint = new Paint();
mPaint.setStyle(Style.FILL);
mPaint.setStrokeWidth(3);
mPaint.setColor(Color.BLUE);
mPaint.setAntiAlias(true);
//canvas.drawPath(path,mPaint);
super.draw(canvas, mapView, shadow);
canvas.drawLine(screenPts.x, screenPts.y, screenPts1.x,
screenPts1.y, mPaint);
canvas.drawLine(screenPts1.x, screenPts1.y, screenPts2.x,
screenPts2.y, mPaint);
canvas.drawLine(screenPts2.x, screenPts2.y, screenPts3.x,
screenPts3.y, mPaint);
return true;
}
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

mapView = (MapView) findViewById(R.id.mapview);

mapView.setBuiltInZoomControls(true);

mapView = (MapView) findViewById(R.id.mapview);



mapView.displayZoomControls(true);
mc = mapView.getController();
String coordinates[] = {"12.958998", "77.658998"};
double lat = Double.parseDouble(coordinates[0]);
double lng = Double.parseDouble(coordinates[1]);

p = new GeoPoint(
(int) (lat * 1E6),
(int) (lng * 1E6));


String coordinates1[] = {"12.95967","77.64918"};
double lat1 = Double.parseDouble(coordinates1[0]);
double lng1 = Double.parseDouble(coordinates1[1]);

p1 = new GeoPoint(
(int) (lat1 * 1E6),
(int) (lng1 * 1E6));

//For geopoint point 3

String coordinates2[] = {"12.96052","77.64171"};
double lat2 = Double.parseDouble(coordinates2[0]);
double lng2 = Double.parseDouble(coordinates2[1]);

p2 = new GeoPoint(
(int) (lat2 * 1E6),
(int) (lng2 * 1E6));

//For geopoint point 4
String coordinates3[] = {"12.96721","77.64141"};
double lat3 = Double.parseDouble(coordinates3[0]);
double lng3 = Double.parseDouble(coordinates3[1]);

p3 = new GeoPoint(
(int) (lat3 * 1E6),
(int) (lng3 * 1E6));



mc.animateTo(p);
mc.animateTo(p1);
mc.animateTo(p2);
mc.animateTo(p3);
mc.setZoom(16);

  //---Add a location marker---
MapOverlay mapOverlay = new MapOverlay();
List listOfOverlays = mapView.getOverlays();
listOfOverlays.clear();
listOfOverlays.add(mapOverlay);

mapView.invalidate();


}

@Overri