How would dynamically draw markers on a Mapview? I’ve got the following code which will hardcode one point in. I’m looking to pull values from a database..
//---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.pushpin);
canvas.drawBitmap(bmp, screenPts.x, screenPts.y-50, null);
I’ve got all the locations in the database. How would I not declare a Point variable etc. for each point the exists in a database table of size N?
Thanks.
Write an OverlayCalss that implements ItemizedOverlay .This is a better method for implementing multiple markers.
You can add the amrkers fetched from the database as :
db = SQLiteDatabase.openDatabase(
Where overlays is an instance of OverlayCAlss that extends ItemizedOverlay and mapOverlays is a list of Overlay items .
Just included the log files for debugging purposes…Decalre the variables used in your file …
Hope this helps … 🙂