Unused drawAt () method for com.google.android.maps.Overlay

Trying to overlay Google maps in an Android program. Inside my labeling method, I have two ways to add a pin. One of them works, and the other does not. Unfortunately, the one that doesn't work is also the only one that has the option to add a shadow! Any help?

@Override
public void draw(android.graphics.Canvas canvas, MapView mapView,
        boolean shadow) {

    Point po = mapView.getProjection().toPixels(mapView.getMapCenter(),
            null);

    // This does _not_ work, but I would really like it to!
    drawAt(canvas, mapView.getResources().getDrawable(R.drawable.map_marker_v),
           po.x, po.y, false);

    // This does work, but only does half the job
    canvas.drawBitmap(BitmapFactory.decodeResource(mapView.getResources(),
            R.drawable.map_marker_v), po.x, po.y, null);


}

Edit: fixed type

+3
source share
2 answers

I think your problem may be that you did not set a border on drawable in drawAt(). You can manually set the borders using Drawable.setBounds(), or you can use the convenient methods ItemizedOverlay boundCenter()or boundCenterBottom().

, , , , Drawable.

+5

, , . , , .

google, , Overlay . , , .

, .

+1

Source: https://habr.com/ru/post/1729109/


All Articles