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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:50:10+00:00 2026-06-08T16:50:10+00:00

i’ve currently a few polygon shapes as shown below that is being drawn onto

  • 0

i’ve currently a few polygon shapes as shown below that is being drawn onto my mapview with the following code

enter image description here

    CustomPolygon customPolygon= data.getCustomPolygonList().get(i);
            Path path = new Path();
            path.setFillType(Path.FillType.EVEN_ODD);
            for(int n=0;n<customPolygon.getCorrdinateList().size();n++)
            {

                GeoPoint sector1 = new GeoPoint((int)(customPolygon.getCorrdinateList().get(n).getLatitude()*1e6), (int)((customPolygon.getCorrdinateList().get(n).getLongitude())*1e6));
                if(n==0){
                    mapView.getProjection().toPixels(sector1, point1_draw);
                    path.moveTo(point1_draw.x,point1_draw.y);
                }else
                {
                    mapView.getProjection().toPixels(sector1, point1_draw);
                    path.lineTo(point1_draw.x,point1_draw.y);
                }
            }

            path.close();
            canvas.drawPath(path, paint);

Right now i’m figuring on how do i know if the ontap button is intersecting any of the polygon. for example if it intersect one of the polygon, a message will display the current polygon.

I’m stuck at the ontap part for the overlay.

    @Override
public boolean onTap(GeoPoint p, MapView ) {



        Point point1_draw = new Point();     
        mapView.getProjection().toPixels(p, point1_draw);


        for (int i =0;i<data.getCustomPolygonList().size();i++)
        {
            CustomPolygon customPolygon= data.getCustomPolygonList().get(i);
            for(int n=0;n<customPolygon.getCorrdinateList().size();n++)
            {
            }

        }

    return  true;
}
  • 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-08T16:50:12+00:00Added an answer on June 8, 2026 at 4:50 pm

    I assume you need some code to check whether the button is inside a polygon right?

    I can’t give you code right now, but here’s a rough algorithm:

    for each line segment in the polygon
      calculate the dot product for the line segment and the line formed by the starting vertex and the point to check
      if all dot products have the same sign, the point is inside the polygon
    

    Note that for this to work, you need the polygon to have a continous winding, i.e. all vertices are either added clockwise or counter clockwise. Additionally, this approach might not always work for concave polygons. Thus you might want to split concave polygons into a series of convex ones.

    For more general (but also more costly) algorithms have a look at this wiki page: http://en.wikipedia.org/wiki/Point_in_polygon

    Another source of information (along with some code): How can I determine whether a 2D Point is within a Polygon?

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
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
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.