J'EMBEDDED une image PNG sur la carte (version 1) en utilisant des superpositions:Android - Créer des projections google map V2
....
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);
}
Je voudrais migrer le code à la version 2. Avez-vous des conseils? Existe-t-il des composants similaires dans Google Map v2?
Meilleures salutations
La capture d'écran.
Ajoutez une capture d'écran pour indiquer clairement ce que vous voulez dessiner. –
Salut Macie, J'ai téléchargé la capture d'écran. Comme vous pouvez le voir, je voudrais mettre sur la carte une image PNG, mais fixée par le coin en haut à gauche (latitude-longitude) et par le coin en bas à droite (latitude-longitude). Si j'effectue un zoom avant ou arrière sur la carte, l'image PNG doit être redimensionnée. –
C'est très facile avec GroundOverlay dans l'API v2. –