Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8068577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:44:07+00:00 2026-06-05T12:44:07+00:00

Here I have used google map and an overlay. I have used an image

  • 0

Here I have used google map and an overlay. I have used an image of pushpin to point to the GeoPoint.

I want to set an OnClickListener event for the push pin. When user touches the pin, I want to toast a message. Below is the code.

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.os.Bundle;
import android.widget.Toast;

public class Googlemap1_6Activity extends MapActivity 
{
    /** Called when the activity is first created. */
    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) 
    {
        // TODO Auto-generated method stub
        super.draw(canvas, mapView, shadow, when);

        Point screenPts =new Point();
            mapView.getProjection().toPixels(p, screenPts);
            Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.pushpin2);
            canvas.drawBitmap(bmp,  screenPts.x, screenPts.y-26, null);


        return true;
    }

    @Override
    public boolean onTap(GeoPoint pl, MapView mapView) {
        // TODO Auto-generated method stub


         if(pl.equals(p))
        {

             Toast.makeText(getBaseContext(),
                        "This is International Airport",
                        Toast.LENGTH_LONG).show();
         }

         return super.onTap(pl, mapView);
}

}

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    String lat_coordinates[] ={"27.700556"};
    String lng_coordinates[] ={"85.3630"}; 

    Double lat = Double.parseDouble(lat_coordinates[0]);
    Double lng = Double.parseDouble(lng_coordinates[0]);

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

    mapView = (MapView) findViewById(R.id.mapView);
    mc=mapView.getController();
    mapView.setBuiltInZoomControls(true);
    mc.setZoom(10); 
    mc.animateTo(p);


    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;
}

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T12:44:09+00:00Added an answer on June 5, 2026 at 12:44 pm

    You Override your own Overlay, so you have to handle Tabs yourself. Why not using ItemizedOverlay. Override the onTab(int index) there and you are done.
    It has also a useful hitTest Method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a google map that used to work here: http://www.comehike.com/outdoors/birds/birds.php Now I see
I have a high-resolution image that I want to use as a tiled map
i have used libxml2.Here when i am getting an XML data as a string
Here is the piece of code that I have used for Java 5.0 TreeSet<Integer>
So here is my problem: I have used a number of interfaces in my
Excuse my limited knoweldge here. In the past I have used Steve Sanderson's method
In my application, i have used C2DM. Here, when i receive a C2DM message/notification,
I used to have tables before to display the content and people here advised
i have an old codebase here, where they used protected member variables. Whether or
I have just downloaded SQL Server 2005 express edition from here: To be used

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.