0

I embedded a PNG image on the map (version 1) using Overlays:

    ....
    Bitmap map_scaled = Bitmap.createScaledBitmap(map_png, map_png.getWidth(), map_png.getHeight(), true);

....

@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
        super.draw(canvas, mapView, false);
        if(shadow) return;
        Projection projection = mapView.getProjection();

        Point leftTop = new Point();
        Point rightTop = new Point();
        Point rightBottom = new Point();
        Point leftBottom = new Point();

        projection.toPixels(topGeoPoint, leftTop);
        projection.toPixels(new GeoPoint(topGeoPoint.getLatitudeE6(), bottomGeoPoint.getLongitudeE6()), rightTop);
        projection.toPixels(bottomGeoPoint, rightBottom);
        projection.toPixels(new GeoPoint(bottomGeoPoint.getLatitudeE6(), topGeoPoint.getLongitudeE6()), leftBottom);

        if (
                (leftTop.x < 0 || leftTop.y < 0) && 
                (rightTop.x < 0 || rightTop.y < 0) && 
                (rightBottom.x < 0 || rightBottom.y < 0) && 
                (leftBottom.x < 0 || leftBottom.y < 0)) {
            // Not on screen? Don't draw the overlay
            return;
        }

        //      GeoPoint mapCenter = mapView.getMapCenter();
        Paint paint = new Paint();
        paint.setFilterBitmap(true);
        paint.setAntiAlias(true);

        canvas.drawBitmap(original, null, new Rect(leftTop.x, leftTop.y, rightBottom.x, rightBottom.y), paint);


}

I would like to migrate the code to version 2. Do you have any advices? Is there any similar components for do that in Google Map v2?

Best regards


The screenshot. enter image description here

Ernesto Rodriguez
  • 257
  • 2
  • 9
  • 26

1 Answers1

0

Maybe I miss understood, but if you want to add markers to your map, you simple can do it like this:

 private MarkerOptions createMapMarker(LocationWO mLocation) {

    MarkerOptions mMarker = new MarkerOptions()
            .position(
                    new LatLng(mLocation.getmLatitude(), mLocation
                            .getmLongitude()))
            .title(mLocation.getmName())
            .snippet(mLocation.getmName())
            .icon(BitmapDescriptorFactory
                    .fromResource(R.drawable.map_pin_debug));
    return mMarker;
}

Check the official doku https://developers.google.com/maps/documentation/android/marker There are examples for drawing shapes at the map as well, if I didn't get your question right: https://developers.google.com/maps/documentation/android/shapes

longi
  • 11,104
  • 10
  • 55
  • 89