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

  • Home
  • SEARCH
  • 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 7495833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:20:48+00:00 2026-05-29T18:20:48+00:00

I using class Overlay to marker place on map.. I want show infomation of

  • 0

I using class Overlay to marker place on map.. I want show infomation of place when i click icon on map (show atm_name and atm_address).
I tried method onTap but it show all infomation of all icon when i click.
Which method should I use to solved my problem.. Help me.
Sorry i use english not good

My Code:

public class atm_markerATM extends Overlay{

    Double lat;
    Double lng;
    Context ct;
    String atm_name;
    String atm_address;

    @Override
    public void draw(Canvas canvas, MapView mapView, boolean shadow) {
        Projection projection = mapView.getProjection();
        if (shadow == false) {
            Double latitude = lat*1E6;
            Double longitude = lng*1E6;
            GeoPoint geoPoint;
            geoPoint = new GeoPoint(latitude.intValue(),longitude.intValue());

            // Convert the location to screen pixelats
            Point point = new Point();
            projection.toPixels(geoPoint, point);

            // Setup the paint
            Paint paint = new Paint();

            Bitmap mBitmap = BitmapFactory.decodeResource(ct.getResources(), R.drawable.hoe);
            canvas.drawBitmap(mBitmap, point.x-8, point.y-38, paint);
        }
        super.draw(canvas, mapView, shadow);
    }

    @Override
    public boolean onTap(GeoPoint point, MapView mapView) {
        return false;
    }

    public void setLocation(Double lat, Double lng, Context ct, String name, String address) {
        this.lat = lat;
        this.lng = lng;
        this.ct = ct;
        this.atm_name = name;
        this.atm_address = address;
    }
}
  • 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-05-29T18:20:52+00:00Added an answer on May 29, 2026 at 6:20 pm

    I’ve used OnTap in my Overlay and it works well.

    In my Draw method I populate a ArrayList of objects which represent the displayed entity (ATM in your case). Each of these object has a latitude and longitude value.

    In onTap I compare the tapped point with the lat/long of each of the object in my ArrayList (populated during Draw). If the tap hits a point in close proximity to an object then I can display it’s details.

    I have some source code which I can post up at some point if this sounds like the way you want to go.

    [Edit] Here is the source code which I’ve hacked out the bits you will need. Note that there are some references to bubbleLayouts etc which you won’t need but it’s easier to leave them in.

    Note that there is always more than one way to do just about anything – this may not be the best way but it works for me 😉

    import java.util.ArrayList;
    import java.util.Iterator;
    import android.content.Context;
    import android.graphics.Bitmap;
    import android.graphics.BitmapFactory;
    import android.graphics.Canvas;
    import android.graphics.Color;
    import android.graphics.Paint;
    import android.graphics.Point;
    import android.graphics.RectF;
    import android.view.View;
    import android.widget.ImageView;
    import android.widget.LinearLayout;
    import android.widget.TextView;
    import com.google.android.maps.GeoPoint;
    import com.google.android.maps.MapView;
    import com.google.android.maps.Projection;
    import com.google.android.maps.MapView.LayoutParams;
    import com.google.android.maps.Overlay;
    
    public class EnhancedStationOverlay extends Overlay {
    
    private MapView _mapView;
    private Context _context;
    private LinearLayout _bubbleLayout;
    private int _defaultMarker;
    private ArrayList<station> _stationLocations;
    private ArrayList<station> _displayedStations;
    
    // private RectF debugHitRect = new RectF();
    
    public EnhancedStationOverlay(int defaultMarker, MapView mapView, LinearLayout bubbleLayout, ArrayList<station> stationList) {
        _stationLocations = stationList;
        _mapView = mapView;
        _context = mapView.getContext();
        _bubbleLayout = bubbleLayout;
        _defaultMarker = defaultMarker;
    }
    
    public boolean onTap(GeoPoint p, MapView mapView) {
    
        station tappedStation = FetchTappedStation(mapView, p);
    
        if (tappedStation != null) {
    
            // Display Bubble containing Location Details
        }
    
        return true;
    }
    
    @Override
    public void draw(Canvas canvas, MapView mapView, boolean shadow) {
    
        Projection projection = mapView.getProjection();
        super.draw(canvas, mapView, shadow);
    
        // Need to resolve top, bottom, left and right coordinates in relation to the map
    
        // Height & Width
        int latSpan = mapView.getLatitudeSpan();
        int lngSpan = mapView.getLongitudeSpan();
    
        // Centre Point
        GeoPoint mapCenter = mapView.getMapCenter();
    
        // Left and Right
        int mapLeftGeo = mapCenter.getLongitudeE6() - (lngSpan / 2);
        int mapRightGeo = mapCenter.getLongitudeE6() + (lngSpan / 2);
    
        // Top and Bottom
        int mapTopGeo = mapCenter.getLatitudeE6() - (latSpan / 2);
        int mapBottomGeo = mapCenter.getLatitudeE6() + (latSpan / 2);
    
        if (shadow != false) {
            // Create an empty ArrayList
            _displayedStations = new ArrayList<station>();
    
            // Loop through stations
            for (station currentStation : _stationLocations) {
    
                // Resolve current station location to a GeoPoint
                GeoPoint point = new GeoPoint((int) currentStation.getLatitude(), (int) currentStation.getLongitude());
    
                // Determine whether it falls within the screens view of the map
                if ((point.getLatitudeE6() > mapTopGeo && point.getLatitudeE6() < mapBottomGeo)
                        && (point.getLongitudeE6() > mapLeftGeo && point.getLongitudeE6() < mapRightGeo)) {
    
                    // Yes it does - configure and place marker (pushpin)
                    Point myPoint = new Point();
                    projection.toPixels(point, myPoint);
    
                    Bitmap stationMarker = BitmapFactory.decodeResource(_context.getResources(), _defaultMarker);
                    canvas.drawBitmap(stationMarker, myPoint.x - 15, myPoint.y - 30, null);
    
                    // Add this location to the collection of displayed locations
                    _displayedStations.add(currentStation);
                }
            }
        }
    }
    
    private station FetchTappedStation(MapView mapView, GeoPoint geo) {
    
        // As in Draw() - Need to resolve top, bottom, left and right coordinates in relation to the map (could refactor this)
        int latSpan = mapView.getLatitudeSpan();
        int lngSpan = mapView.getLongitudeSpan();
        GeoPoint mapCenter = mapView.getMapCenter();
        int mapLeftGeo = mapCenter.getLongitudeE6() - (lngSpan / 2);
        int mapRightGeo = mapCenter.getLongitudeE6() + (lngSpan / 2);
        int mapTopGeo = mapCenter.getLatitudeE6() - (latSpan / 2);
        int mapBottomGeo = mapCenter.getLatitudeE6() + (latSpan / 2);
    
        // Track which MapLocation was hit…if any
        station hitMapLocation = null;
    
        RectF hitTestRecr = new RectF();
        Point screenCoords = new Point();
        Point tappedCoords = new Point();
    
        Iterator<station> iterator = _displayedStations.iterator();
    
        // Iterate over displayed stations...
        while (iterator.hasNext()) {
            station testLocation = iterator.next();
    
            // Translate MapLocation lat/long to screen coordinates
            GeoPoint test = new GeoPoint((int) testLocation.getLatitude(), (int) testLocation.getLongitude());
    
            Projection projection = mapView.getProjection();
            projection.toPixels(test, screenCoords);
    
            if (screenCoords.x != 0 && screenCoords.y != 0) {
                // Create a 'hit testing' rectangle
                hitTestRecr.set(-20, -50, 20, 15);
    
                // Next, offset the Rectangle 'surround' current location’s
                // icon on the screen.
                hitTestRecr.offset(screenCoords.x, screenCoords.y);
    
                // Finally test for match between ‘hit’ Rectangle and
                // location clicked by the user.
                // If a hit occurred, then we stop processing and return the
                // result;
                projection.toPixels(geo, tappedCoords);
                if (hitTestRecr.contains(tappedCoords.x, tappedCoords.y)) {
                    hitMapLocation = testLocation;
                    break;
                }
            }
    
        }
    
        return hitMapLocation;
    }
    

    }

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

Sidebar

Related Questions

Following Mootools class helps developer to draw a circle overlay on Google Map using
Using class name I am firing a click event in jquery. Class names are
I want to create a new object using Class::DBI. One of the fields of
Using garb (http://github.com/vigetlabs/garb) i need to fetch the same Map Overlay XML, like Google
i am using MapActivity in my application to show map and for that i
I am using the following map class to use maps in my android app...
Project Background: I am writing a map tile overlay class for java that can
I am using jQuery's UI dialogs and I want to add a custom method.
i load a class using Class.forName(klassname,false,loader) After this i create an instance using klass.newInstance();
I am using: class ISearchFuncs : public Osp::Ui::IActionEventListener , public Osp::Ui::ITextEventListener , public Osp::Ui::IScrollPanelEventListener

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.