Android 数据库与MapView总结
2010-11-05 00:54:34 来源:WEB开发网this.drawableID = drawableID;
}
public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when){
Projection projection=mapView.getProjection();
if(shadow==false){
GeoPoint gp=new GeoPoint((int)this.geoLatitude, (int)this.geoLongitude);
Point point=new Point();
projection.toPixels(gp, point);
Paint paint=new Paint();
paint.setAntiAlias(true);
Bitmap bm=BitmapFactory.decodeResource(mapView.getResources(), this.drawableID);
canvas.drawBitmap(bm, point.x, point.y, paint);
}
return super.draw(canvas, mapView, shadow, when);
}
public void updateLocation(Location location)
{
this.mLocation = location;
}
public Location getLocation()
{
return mLocation;
}
}
package irdc.ex10_06;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.location.Location;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.Projection;
public class GeoPointImageOverlay extends Overlay
{
private Location mLocation;
private int drawableID;
private double geoLatitude,geoLongitude;
/* 建构方法一,传入Location对象 */
public GeoPointImageOverlay(Location location, int drawableID)
{
this.mLocation = location;
this.drawableID = drawableID;
/* 取得Location的经纬度 */
this.geoLatitude = this.mLocation.getLatitude()*1E6;
更多精彩
赞助商链接