I want to overlay a map image (.jpg) over the Google Maps mapview.
The problem is: The overlay image is not showing, who knows what's the
problem?
There is no error in logcat and the MapView is working.
The code:
package nl.ultimo.android.skikaart;
import java.util.List;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.Bundle;
public class MapsActivity extends MapActivity
{
Bitmap bmp; //Loaded bitmap in memory
GeoPoint min; //Top left corner (lat/long)
GeoPoint max; //Right bottom corner (lat/long)
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
float lat1 = 45.19775f;
float lng1 = 6.28418333f;
float lat2 = 45.2636667f;
float lng2 = 6.17431667f;
min = new GeoPoint((int)(lat1 * 1E6), (int)(lng1 * 1E6)); // bounding rectangle
max = new GeoPoint((int)(lat2 * 1E6), (int)(lng2 * 1E6));
MapView mapView = (MapView) findViewById(R.id.mapView);
MapController ctrl = mapView.getController();
int x = (min.getLongitudeE6() + max.getLongitudeE6())/ 2; //Select map center
int y = (min.getLatitudeE6() + max.getLatitudeE6())/ 2;
ctrl.setCenter(new GeoPoint(y,x));
ctrl.setZoom(12); //Set scale
mapView.setBuiltInZoomControls(true); //Enable zoom controls
//Add overlay
MapOverlay mapOverlay = new MapOverlay();
List<Overlay> listOfOverlays = mapView.getOverlays();
listOfOverlays.clear();
listOfOverlays.add(mapOverlay);
mapView.invalidate();
}
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(min, screenPts);
//The overlay image
Bitmap bmp = BitmapFactory.decodeResource(getResources(),R.drawable.skikaart);
//Prepare two rectangles (pixels)
Point top_left = new Point();
mapView.getProjection().toPixels(min, top_left);
Point bottom_right = new Point();
mapView.getProjection().toPixels(max, bottom_right);
Rect src = new Rect( 0,0,bmp.getWidth() - 1, bmp.getHeight() - 1 );
Rect dst = new Rect( top_left.x, bottom_right.y,bottom_right.x,top_left.y );
canvas.drawBitmap(bmp, src, dst, null);
return true;
}
}
#Override
protected boolean isRouteDisplayed() {
return false;
}
}
to see marker you need to do next
Drawable drawable = ...set your marker drawable
drawable.setBounds(-drawable.getIntrinsicWidth() / 2, -drawable.getIntrinsicHeight(), drawable.getIntrinsicWidth() / 2, 0);
overlayitem.setMarker(drawable);
Just to make things clear here is a quote from reference
"The setBounds(Rect) method must be called to tell the Drawable where it is drawn and how large it should be."
Your code has one minor mistake.
Change
Rect dst = new Rect( top_left.x, bottom_right.y,bottom_right.x,top_left.y );
to
Rect dst = new Rect( top_left.x, top_left.y,bottom_right.x,bottom_right.y );
and you should be good.
Remember that draw() is called each time the overlay needs to be rendered. When the map is being moved by the user, this could happen multiple times per second!!
You need to load the resource only ONCE, then only draw the bitmap onto the canvas during the draw invocation.
Also, your current implementation is highly coupled with the actual Activity.
in your activity
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
...
map.getOverlays().add(new PNGMapOverlay(getResources(), R.drawable.bitmap_id));
}
// allows re-factoring into separate class/file
class MapOverlay extends com.google.android.maps.Overlay
{
private Bitmap bitmap;
public MapOverlay(Resources resources, int resourceId) {
bitmap = BitmapFactory.decodeResource(resources, resourceId);
}
#Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
...
canvas.drawBitmap(bmp, src, dst, null);
}
}
Change this code
min = new GeoPoint((int)(lat1 * 1E6), (int)(lng2 * 1E6)); // bounding rectangle
max = new GeoPoint((int)(lat2 * 1E6), (int)(lng1 * 1E6));
instead of
min = new GeoPoint((int)(lat1 * 1E6), (int)(lng1 * 1E6)); // bounding rectangle
max = new GeoPoint((int)(lat2 * 1E6), (int)(lng2 * 1E6));
and try its working.
You have to add overlays into your listOfOverlays. Then only it will be shown on the map. For that you have to create an overlayitem using ur geopoint and then add it to the list of overlays.
For eg:
GeoPoint point = new GeoPoint((int) (latitude * 1E6), (int) (longitude * 1E6));
OverlayItem overlayItem = new OverlayItem(point, "", "");
listOfOverlays.addOverlay(overlayItem);
mapView.invalidate();
Try and see. If you face any issue, please add as comments.
I just spent ages pulling my hair out with the same problem as you. Turned out removing android:layout_weight="1" from my MapView declaration resolved the problem. Don't ask me why!
Related
I've been working on this for a while now, but I still have not gotten the result I'm looking for. I'm trying to create an app to display our mountain bike trails so you can see where you are when you're on them. I started by manually copying coordinates from my kml file and pasting them as Geopoints with this code which worked until I got to point 80. Then the LogCat gave an error rejecting large method, and I still have hundreds more to go:
import java.util.List;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.Projection;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Point;
import android.os.Bundle;
public class TrailMaps extends MapActivity {
private List mapOverlays;
private Projection projection;
private MapController mc;
private MapView mapView;
private GeoPoint gP;
private MyOverlay myoverlay;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapView = (MapView) findViewById(R.id.mapview);//Creating an instance of MapView
mapView.setBuiltInZoomControls(true);//Enabling the built-in Zoom Controls
gP = new GeoPoint(43311836,-91777756);//Creating a GeoPoint
mc = mapView.getController();
mc.setCenter(gP);
mc.setZoom(15);//Initializing the MapController and setting the map to center at the
mapOverlays = mapView.getOverlays();
projection = mapView.getProjection();
myoverlay = new MyOverlay();
mapOverlays.add(myoverlay);
}
class MyOverlay extends Overlay{
public MyOverlay(){
}
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
super.draw(canvas, mapView, shadow);
Paint paint;
paint = new Paint();
paint.setDither(true);
paint.setColor(Color.RED);
paint.setStyle(Paint.Style.FILL_AND_STROKE);
paint.setStrokeJoin(Paint.Join.ROUND);
paint.setStrokeWidth(2);
GeoPoint gp1 = new GeoPoint(43311836,-91777756);
GeoPoint gp2 = new GeoPoint(43311718,-91777699);
GeoPoint gp3 = new GeoPoint(43311718,-91777699);
GeoPoint gp4 = new GeoPoint(43311666,-91777627);
GeoPoint gp5 = new GeoPoint(43311624,-91777541);
Point pt1 = new Point();
Point pt2 = new Point();
Point pt3 = new Point();
Point pt4 = new Point();
Point pt5 = new Point();
Path path1 = new Path();
Path path2 = new Path();
Path path3 = new Path();
projection.toPixels(gp1,pt1);
projection.toPixels(gp2, pt2);
projection.toPixels(gp3, pt3);
projection.toPixels(gp4, pt4);
projection.toPixels(gp5, pt5);
path1.moveTo(pt1.x, pt1.y);
path1.lineTo(pt2.x, pt2.y);
path2.moveTo(pt3.x,pt3.y);
path2.lineTo(pt4.x, pt4.y);
path3.moveTo(pt4.x,pt4.y);
path3.lineTo(pt5.x,pt5.y);
canvas.drawPath(path1, paint);
canvas.drawPath(path2, paint);
canvas.drawPath(path3, paint);
}
}
#Override
protected boolean isRouteDisplayed() {
return false;
}
}
Then I tried to parse the kml file as in this example: How to draw a path on a map using kml file?
But this is taking my coordinates and finding the nearest streets and overlaying a route. My coordinates are not along the street they are in a park off road, so how else should I do it?
Right now I'm open to any suggestions. Is there a better way to parse the kml file, do it locally vs going to http://maps.google.com/maps?, overlaying it as an image, or a whole new direction completely... Any suggestions would be much appreciated.
Thanks
I wonder if there is a chance to set a final Overlay in Google Maps. I wanna set my cross hairs this way, so that it isn't moving while zooming.
Code:
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map_view);
initData();
mapView = (MapView) findViewById(R.id.mapView);
mapView.setSatellite(true);
mapView.setTraffic(true);
mapView.setBuiltInZoomControls(true);
controller = mapView.getController();
controller.animateTo(coordinate);
controller.setZoom(18);
// TODO:
CrossHairsOverlay chOverlay = new CrossHairsOverlay();
// Pin
MapOverlay mapOverlay = new MapOverlay();
mapOverlay.setPointToDraw(coordinate);
List<Overlay> listOfOverlays = mapView.getOverlays();
listOfOverlays.clear();
listOfOverlays.add(mapOverlay);
listOfOverlays.add(chOverlay);
}
Cross hairs:
public class CrossHairsOverlay extends Overlay {
public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) {
super.draw(canvas, mapView, shadow);
Projection projection = mapView.getProjection();
Point centerPoint = projection.toPixels(mapView.getMapCenter(), null);
Bitmap crossHairs = BitmapFactory.decodeResource(getResources(), R.drawable.cross_hair);
canvas.drawBitmap(crossHairs, centerPoint.x - (int)(27 * dpi + 0.5f), centerPoint.y - (int)(27 * dpi + 0.5f), new Paint());
return true;
}
}
If I use it this way, it recenters after zooming is finished. Left/right draging works correct. I don't really wanna set a "ZoomListener" and redraw all the time. I hope there is a bether solution to do this.
Thanks
Forgive me for not fully understanding your question...
But, to draw to a simple point no need to use the projection, just draw your bitmap strictly to the center of the mapview.
ie...
// make the coordinated constant also.
canvas.drawBitam(bitmap, center.x-(imageWidth/2), center.y-(imageHeight/2),new Paint());
where center.x and center.y are just equal to
Point center = new Point(canvas.getWidth()/2,canvas.getHeight()/2);
Also dont reload your bitmap on every onDraw!, memory leak ftl ;).
I have some a shape file which I have converted to a KML file that I wish to read coordinates from and then draw paths between the coordinates on a MapView. With the help of this great post: How to draw a path on a map using kml file? I have been able to read the the KML into an ArrayList of "Placemarks". This great blog post then showed how to take a list of GeoPoints and draw a path: http://djsolid.net/blog/android---draw-a-path-array-of-points-in-mapview
The example in the above post only draws one path between some points however and since I have many more paths than that I am running into some performance problems. I'm currently adding a new RouteOverlay for each of the separate paths. This results in me having over 800 overlays when they have all been added. This has a performance hit and I would love some input on what I can do to improve it.
Here are some options I have considered:
Try to add all the points to a List which then can be passed into a class that will extend Overlay. In that new class perhaps it would be possible to add and draw the paths in a single Overlay layer? I'm not sure on how to implement this though since the paths are not always intersecting and they have different start and end points. At the moment I'm adding each path which has several points to it's own list and then I add that to an Overlay. That results in over 700 overlays...
Simplify the KML or SHP. Instead of having over 700 different paths, perhaps there is someway to merge them into perhaps 100 paths or less? Since alot of paths are intersected at some point it should be possible to modify the original SHP file so that it merges all intersections. Since I have never worked with these kinds of files before I have not been able to find a way to do this in GQIS. If someone knows how to do this I would love for some input on that. Here is a link to the group of shape files if you are interested:
http://danielkvist.net/cprg_bef_cbana_polyline.shp
http://danielkvist.net/cprg_bef_cbana_polyline.shx
http://danielkvist.net/cprg_bef_cbana_polyline.dbf
http://danielkvist.net/cprg_bef_cbana_polyline.prj
Anyway, here is the code I'm using to add the Overlays. Many thanks in advance.
RoutePathOverlay.java
package net.danielkvist;
import java.util.List;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Point;
import android.graphics.RectF;
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 RoutePathOverlay extends Overlay
{
private int _pathColor;
private final List<GeoPoint> _points;
private boolean _drawStartEnd;
public RoutePathOverlay(List<GeoPoint> points)
{
this(points, Color.RED, false);
}
public RoutePathOverlay(List<GeoPoint> points, int pathColor, boolean drawStartEnd)
{
_points = points;
_pathColor = pathColor;
_drawStartEnd = drawStartEnd;
}
private void drawOval(Canvas canvas, Paint paint, Point point)
{
Paint ovalPaint = new Paint(paint);
ovalPaint.setStyle(Paint.Style.FILL_AND_STROKE);
ovalPaint.setStrokeWidth(2);
int _radius = 6;
RectF oval = new RectF(point.x - _radius, point.y - _radius, point.x + _radius, point.y + _radius);
canvas.drawOval(oval, ovalPaint);
}
public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when)
{
Projection projection = mapView.getProjection();
if (shadow == false && _points != null)
{
Point startPoint = null, endPoint = null;
Path path = new Path();
// We are creating the path
for (int i = 0; i < _points.size(); i++)
{
GeoPoint gPointA = _points.get(i);
Point pointA = new Point();
projection.toPixels(gPointA, pointA);
if (i == 0)
{ // This is the start point
startPoint = pointA;
path.moveTo(pointA.x, pointA.y);
}
else
{
if (i == _points.size() - 1)// This is the end point
endPoint = pointA;
path.lineTo(pointA.x, pointA.y);
}
}
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setColor(_pathColor);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(3);
paint.setAlpha(90);
if (getDrawStartEnd())
{
if (startPoint != null)
{
drawOval(canvas, paint, startPoint);
}
if (endPoint != null)
{
drawOval(canvas, paint, endPoint);
}
}
if (!path.isEmpty())
canvas.drawPath(path, paint);
}
return super.draw(canvas, mapView, shadow, when);
}
public boolean getDrawStartEnd()
{
return _drawStartEnd;
}
public void setDrawStartEnd(boolean markStartEnd)
{
_drawStartEnd = markStartEnd;
}
}
MyMapActivity
package net.danielkvist;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
public class MyMapActivity extends MapActivity
{
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MapView mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
String url = "http://danielkvist.net/cprg_bef_cbana_polyline_simp1600.kml";
NavigationDataSet set = MapService.getNavigationDataSet(url);
drawPath(set, Color.parseColor("#6C8715"), mapView);
}
/**
* Does the actual drawing of the route, based on the geo points provided in
* the nav set
*
* #param navSet
* Navigation set bean that holds the route information, incl.
* geo pos
* #param color
* Color in which to draw the lines
* #param mMapView01
* Map view to draw onto
*/
public void drawPath(NavigationDataSet navSet, int color, MapView mMapView01)
{
ArrayList<GeoPoint> geoPoints = new ArrayList<GeoPoint>();
Collection overlaysToAddAgain = new ArrayList();
for (Iterator iter = mMapView01.getOverlays().iterator(); iter.hasNext();)
{
Object o = iter.next();
Log.d(BikeApp.APP, "overlay type: " + o.getClass().getName());
if (!RouteOverlay.class.getName().equals(o.getClass().getName()))
{
overlaysToAddAgain.add(o);
}
}
mMapView01.getOverlays().clear();
mMapView01.getOverlays().addAll(overlaysToAddAgain);
int totalNumberOfOverlaysAdded = 0;
for(Placemark placemark : navSet.getPlacemarks())
{
String path = placemark.getCoordinates();
if (path != null && path.trim().length() > 0)
{
String[] pairs = path.trim().split(" ");
String[] lngLat = pairs[0].split(","); // lngLat[0]=longitude
// lngLat[1]=latitude
// lngLat[2]=height
try
{
if(lngLat.length > 1 && !lngLat[0].equals("") && !lngLat[1].equals(""))
{
GeoPoint startGP = new GeoPoint(
(int) (Double.parseDouble(lngLat[1]) * 1E6),
(int) (Double.parseDouble(lngLat[0]) * 1E6));
GeoPoint gp1;
GeoPoint gp2 = startGP;
geoPoints = new ArrayList<GeoPoint>();
geoPoints.add(startGP);
for (int i = 1; i < pairs.length; i++)
{
lngLat = pairs[i].split(",");
gp1 = gp2;
if (lngLat.length >= 2 && gp1.getLatitudeE6() > 0
&& gp1.getLongitudeE6() > 0
&& gp2.getLatitudeE6() > 0
&& gp2.getLongitudeE6() > 0)
{
// for GeoPoint, first:latitude, second:longitude
gp2 = new GeoPoint(
(int) (Double.parseDouble(lngLat[1]) * 1E6),
(int) (Double.parseDouble(lngLat[0]) * 1E6));
if (gp2.getLatitudeE6() != 22200000)
{
geoPoints.add(gp2);
}
}
}
totalNumberOfOverlaysAdded++;
mMapView01.getOverlays().add(new RoutePathOverlay(geoPoints));
}
}
catch (NumberFormatException e)
{
Log.e(BikeApp.APP, "Cannot draw route.", e);
}
}
}
Log.d(BikeApp.APP, "Total overlays: " + totalNumberOfOverlaysAdded);
mMapView01.setEnabled(true);
}
#Override
protected boolean isRouteDisplayed()
{
// TODO Auto-generated method stub
return false;
}
}
Edit: There are of course some more files I'm using but that I have not posted. You can download the complete Eclipse project here: http://danielkvist.net/se.zip
Have you considered rendering all the paths to a bitmap and then use that as a overlay, and of-course you would need to render it again if the user zooms in or out or moves the map alot. Making the bitmap 2 or 4 times as large as the screen (be care-full not to use up all memory here) you should be able to get some zooming in and out a-swell as allow for a bit of panning until you need to render it again.
Rendering it like a quad-tree (with week references to the bitmaps in the tree) would allow for some caching and possibly big performance improvements.
Going with a quad-tree is not an easy approach but might be worth the effort if you have the time and knowledge for it. I believe this roughly is how the google maps handles its map tiles.
I am using the osmdroid-android 3.0.5.jar instead of Google map api to show the location in map by using geo-coordinate.
Well i am able to get map in android emulator but the problem is the overlay i am using to point to location is wrong.
Here's my code :
public class MainActivity extends Activity {
/** Called when the activity is first created. */
private MapView osmMapView;
private MapController controller;
private Projection projection;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
osmMapView = (MapView) findViewById(R.id.osm_map_view);
this.osmMapView.setTileSource(TileSourceFactory.MAPNIK);
this.osmMapView.setBuiltInZoomControls(true);
this.osmMapView.setMultiTouchControls(true);
this.projection = this.osmMapView.getProjection();
this.controller = this.osmMapView.getController();
this.controller.setZoom(5);
List<Overlay> overLayList = osmMapView.getOverlays();
overLayList.add(new ScaleBarOverlay(this));
overLayList.add(new PutOverLayOnMap(this));
}
private class PutOverLayOnMap extends Overlay {
public PutOverLayOnMap(Context ctx) {
super(ctx);
}
#Override
protected void draw(Canvas c, MapView osmv, boolean shadow) {
Paint paint = new Paint();
paint.setColor(Color.RED);
paint.setDither(true);
paint.setStyle(Paint.Style.FILL_AND_STROKE);
paint.setStrokeJoin(Paint.Join.ROUND);
paint.setStrokeCap(Paint.Cap.ROUND);
paint.setStrokeWidth(10);
Point point = new Point();
GeoPoint geoPoint = new GeoPoint((int)(41.057121 * 1E6), (int)(-73.561867 * 1E6));
projection.toPixels(geoPoint, point);
c.drawPoint(point.x, point.y, paint);
System.out.println("GeoPoint(OSM) : "+geoPoint.getLatitudeE6()+" #### "+geoPoint.getLongitudeE6());
}
}
The following is my main.xml :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<org.osmdroid.views.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_centerInParent="true"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:id="#+id/osm_map_view"
renderer="CloudMadeStandardTiles"
cloudmadeStyle="1"
/>
</LinearLayout>
As you can see I am using
GeoPoint geoPoint = new GeoPoint((int)(41.057121 * 1E6), (int)(-73.561867 * 1E6));
which is the geo-coordinate of Stamford US Now the red dot is showing somewhere Africa, center of the map (intersection of latitude & longitude).
What i am doing wrong?
You need to get the projection in the draw method. The javadocs for getProjection tell you
public MapView.Projection getProjection()
Get a projection for converting between screen-pixel coordinates and latitude/longitude coordinates. You should not hold on to this object for more than one draw, since the projection of the map could change.
So in your draw method, insert the line as shown below
....
paint.setStrokeWidth(10);
Point point = new Point();
projection = osmMapView.getProjection(); // <<<<<<<<<<<<<<<<< ADD THIS LINE
GeoPoint geoPoint = new GeoPoint((int) (41.057121 * 1E6),
(int) (-73.561867 * 1E6));
projection.toPixels(geoPoint, point);
.....
This should fix it.
I am trying to show the users current location with the default blue dot in android. In my maps page I also have a layout that shows different points of interest. Im having trouble figuring out what to put for some of the variables and was wondering if someone could help me out.
This is what I'm using so far to show my location.
Location location = locationManager
.getLastKnownLocation(bestProvider);
try {
GeoPoint myPoint2 = new GeoPoint(
(int) (location.getLatitude() * 1E6),
(int) (location.getLongitude() * 1E6));
newoverlay.drawMyLocation(null, mapView, location, myPoint2,
1000);
mapOverlays.add(newoverlay);
} catch (NullPointerException e) {
GeoPoint myPoint2 = new GeoPoint((int) (-1 * 1E6),
(int) (-1 * 1E6));
**newoverlay.drawMyLocation(null, mapView, location, myPoint2,
1000);**
mapOverlays.add(newoverlay);
}
I'm not sure what to put as the Canvas so I placed it with null so that it would compile. I'm using the location from a location Manager and I have my geopoint from the location variable. I'm also unsure what the "when" parameter is supposed to be.
I was also wondering how the blue bubble knows to move with the person, does the picture update every x milliseconds depending on the "when" parameter?
So far the app isn't crashing, but it is also not showing the blue dot at any location.
I'm sure I just need help with finding what the canvas parameter should be.
Thanks
try this way in your map activity
class CurOverlay extends Overlay {
private GeoPoint pointToDraw;
public void setPointToDraw(GeoPoint point) {
pointToDraw = point;
}
public GeoPoint getPointToDraw() {
return pointToDraw;
}
#Override
public boolean draw(Canvas canvas, MapView curmapView, boolean shadow,
long when) {
super.draw(canvas, curmapView, shadow);
// convert point to pixels
Point screenPts = new Point();
curmapView.getProjection().toPixels(pointToDraw, screenPts);
// add marker
Bitmap bmp = BitmapFactory.decodeResource(getResources(),
R.drawable.pinsource);
canvas.drawBitmap(bmp, screenPts.x - 28, screenPts.y - 48, null);
return true;
}
}
i hope this will work for you.