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 7775711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:42:03+00:00 2026-06-01T17:42:03+00:00

I’m currently making an android map based app. The purpose of this app is

  • 0

I’m currently making an android map based app. The purpose of this app is to display complex overlays on a mapview. To do this I’m using custom overlays and overriding draw() function.

That part is working perfectly and now I’d like to handle onTap events for each overlay. What I’m currently doing:

public class MapOverlay extends Overlay {


    public MapOverlay(Kml kml,String color,Projection projection){
    }   

    public void draw(Canvas canvas, MapView mapv, boolean shadow){
        super.draw(canvas, mapv, shadow);

        // draw path...
    }

    @Override
    public boolean onTap(GeoPoint gp, MapView mapView) {
        Log.i("Overlay","Say whaaaat!");
        return super.onTap(gp, mapView);
    }
}

As expected, each overlay is covering the entire mapview, so when I tap on an overlay, every overlays fire the onTap event. Say I have 6 overlay, I can’t tell which path has been tapped on.

Is there a solution to do that?

UPDATE:

Now I’ve succeeded displaying markers on my map using ItemizedOverlay (tied ItemizedBaloonOverlay as well) but it’s not exactly what I want.

I’d like something like a PolygonOverlay that will detect if the tap was done inside the polygon and only fire a tap event in that case.

Thanks

  • 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-01T17:42:04+00:00Added an answer on June 1, 2026 at 5:42 pm

    Based on this answer from another post, I have built my custom overlay and it works! So basically, no need of ItemizedOverlay stuff (except if you want to display an overlayitem).

    Just take my previous MapOverlay class and add the basic onTap() function:

    public class MapOverlay extends Overlay {
    
        private Path path;
    
        public MapOverlay(){
            super();
        }
    
        @Override
        public void draw(Canvas canvas, MapView mapv, boolean shadow) {
            super.draw(canvas, mapv, shadow);
    
                // draw your path and store it in variable path
        }
    
        @Override
        public boolean onTap(GeoPoint geoPoint, MapView mapView) {
    
            RectF rectF = new RectF();
            path.computeBounds(rectF, true);
            Region region = new Region();
            region.setPath(path, new Region((int) rectF.left, (int) rectF.top, (int) rectF.right, (int) rectF.bottom));
    
            Point point = new Point();
            mapView.getProjection().toPixels(geoPoint, point);
    
            if (region.contains(point.x, point.y)) {
                Log.d("onTap", point.x+" "+point.y);
            }
    
            return super.onTap(geoPoint, mapView);
        }
    
    }
    

    And that’s it!
    The only thing left is to check the z-order if you only want to fire the one upside. Shouldn’t be a big deal if I keep track of it in my MapOverlay class.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,

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.