Google Map key in Android?

Posted by Amandeep singh on Stack Overflow See other posts from Stack Overflow or by Amandeep singh
Published on 2012-04-06T05:18:41Z Indexed on 2012/04/06 5:29 UTC
Read the original article Hit count: 266

Filed under:
|

I am developing an android app in which i have to show map view i have done it once in a previous app but the key i used in the previous is not working int his app . It is just showing a pin in the application with blank screen. Do i have to use a different Map key for each project , If not Kindly help me how can i use my previous Key in this. and also I tried generating a new key but gave the the same key back .

Here is the code i used

  public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.map);
        btn=(Button)findViewById(R.id.mapbtn);
        str1=getIntent().getStringExtra("LATITUDE");
        str2=getIntent().getStringExtra("LONGITUDE");





        mapView =  (MapView)findViewById(R.id.mapView1);
        //View zoomView = mapView.getZoomControls(); 

        mapView.setBuiltInZoomControls(true);
         //mapView.setSatellite(true);
         mc = mapView.getController();
         btn.setOnClickListener(this);

          MapOverlay mapOverlay = new MapOverlay();
            List<Overlay> listOfOverlays = mapView.getOverlays();
            listOfOverlays.clear();
            listOfOverlays.add(mapOverlay); 


            String coordinates[] = {str1,  str2};
            double lat = Double.parseDouble(coordinates[0]);
            double lng = Double.parseDouble(coordinates[1]);

            p = new GeoPoint(
                (int) (lat * 1E6), 
                (int) (lng * 1E6));

            mc.animateTo(p);
            mc.setZoom(17); 
            mapView.invalidate();

        //mp.equals(o);
    }
    @Override
    protected boolean isRouteDisplayed() {
        // TODO Auto-generated method stub
        return false;
    }
    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);                   
            Paint mPaint = new Paint();
            mPaint.setDither(true);
            mPaint.setColor(Color.RED);
            mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
            mPaint.setStrokeJoin(Paint.Join.ROUND);
            mPaint.setStrokeCap(Paint.Cap.ROUND);
            mPaint.setStrokeWidth(2);

            //---translate the GeoPoint to screen pixels---
            Point screenPts = new Point();
            mapView.getProjection().toPixels(p, screenPts);

            //---add the marker---
            Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.pin);            
            canvas.drawBitmap(bmp, screenPts.x, screenPts.y-50, null);         
            return true;
        }

Thanks....

© Stack Overflow or respective owner

Related posts about android

Related posts about google-maps