Hello, I'm trying to make my USER POSITION overlay to rotate according
to the orientation.
Here is the method that calls for the overlay:
protected void createAndShowUserOverlay(Location newLocation) {
List<Overlay> useroverlays = mapView.getOverlays();
// first remove old overlay
if (useroverlays.size() > 0) {
for (Iterator iterator =
useroverlays.iterator();
iterator.hasNext();) {
iterator.next();
iterator.remove();
}
}
// transform the location to a geoPoint
GeoPoint geopoint = new GeoPoint((int)
(newLocation.getLatitude() *
1E6), (int) (newLocation.getLongitude() * 1E6));
float bear = newLocation.getBearing();
// initialize icon
Drawable icon =
getResources().getDrawable(R.drawable.user2);
icon.setBounds(0, 0, icon.getIntrinsicWidth(),
icon.getIntrinsicHeight());
// create my overlay and show it
userOverlay useroverlay = new userOverlay(icon);
OverlayItem item = new OverlayItem(geopoint, "I'm
here", null);
useroverlay.addItem(item);
mapView.getOverlays().add(useroverlay);
mc.animateTo(geopoint);
mapView.postInvalidate();
}
And here is the draw method on the userOverlay class:
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
super.draw(canvas, mapView, false);
boundCenter(marker);
}
I want to implement this matrix to make the marker rotate, but I don't
know where or how to place it, in order to make the marker rotate
depending on the ''ori'' value, which I'll implement after:
Paint paint = new Paint();
Point pt = new Point();
mapView.getProjection().toPixels(p, pt);
Bitmap bmp =
BitmapFactory.decodeResource(getResources(),R.drawable.pointer);
Matrix matrix = new Matrix();
matrix.postTranslate(-25, -25);
matrix.postRotate(ori);
matrix.postTranslate(pt.x, pt.y);
paint.setAntiAlias(true);
paint.setFilterBitmap(true);
canvas.drawBitmap(bmp, matrix, paint);
Any suggestions ? Should I override the draw method on the userOverlay
class? Or I have to put this on the main class? I'm mixing 2 or 3
tutorials and I'm not quite sure how to merge them together..
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en