Home > DeveloperSection > Forums > Implement Pushin on google Map
Monaj Singh
Monaj Singh

Total Post:41

Points:287
Posted on    January-11-2016 10:54 PM

 Android Android  Google API 
Ratings:


 1 Reply(s)
 206  View(s)
Rate this:
I am implementing to show the particular location on the map and on the same location i want to put the pushpin notification. I have tried to sove this in my way using  below code but it showing nullpointer exception, please suggest me the right solution to implement the markers
public class MapDemoActivity extends MapActivity {
 MapView mapView; 
 MapController mc;
 GeoPoint p;
 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(p, screenPts);

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

 public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mapView = (MapView) findViewById(R.id.mapView);

        mapView.setBuiltInZoomControls(true);
        mc.animateTo(p);
        mc.setZoom(17); 

        //---Add a location marker---
        MapOverlay mapOverlay = new MapOverlay();
        List<Overlay> listOfOverlays = mapView.getOverlays();
        listOfOverlays.clear();
        listOfOverlays.add(mapOverlay);        

        mapView.invalidate();

    }
@Override
protected boolean isRouteDisplayed() {
    // TODO Auto-generated method stub
    return false;
}


Mayank Tripathi
Mayank Tripathi

Total Post:397

Points:3117
Supported
Posted on    January-11-2016 11:17 PM


Don't want to miss updates? Please click the below button!

Follow MindStick