It must be an overlay. It's a ski piste map. If i use the following GeoPoints than the overlay is visible, but not on the correct location:
min = new GeoPoint(45321389,6294167); max = new GeoPoint(45423889,6401667); If i use this GeoPoints than it's NOT visible: min = new GeoPoint(45285650,6174317); max = new GeoPoint(45197750,6306150); The correct points are (in the programs "MapEdit" and "Google Maps"): Left upper corner: N45°17.139' E6°10.459' Right lower corner: N45°11.865' E6°18.369' How to covert this to the correct microdegrees for GeoPoint()? On 12 mrt, 05:02, lbendlin <[email protected]> wrote: > Does it have to be an overlay? If it's just an image then you can > simply add it as a view to the mapView. > > An overlay is just a layer. Unless you fill it with objects, nothing > will show. > > On Mar 10, 1:54 pm, Bastiaan <[email protected]> wrote: > > > > > > > > > Hello, > > > 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; > > } > > > } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

