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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:36:29+00:00 2026-06-02T06:36:29+00:00

I used this function to draw a path between two points. I get the

  • 0

I used this function to draw a path between two points. I get the coordinates from Google’s API, and there’s no problem with this. My problem is, how can I specify whether a particular point is within the path I draw or not? I’m trying to use CGContextPathContainsPoint(), but with no luck.

-(void)updateRouteView {
    CGContextRef context =  CGBitmapContextCreate(nil,
                                                 routeView.frame.size.width,
                                                 routeView.frame.size.height,
                                                 8,
                                                 4 * routeView.frame.size.width,
                                                 CGColorSpaceCreateDeviceRGB(),
                                                 kCGImageAlphaPremultipliedLast);

    CGContextSetStrokeColorWithColor(context, lineColor.CGColor);
    CGContextSetRGBFillColor(context, 0.0, 0.0, 1.0, 1.0);
    CGContextSetLineWidth(context, 5.0);

    // routes : array of coordinates of the path
    for (int i = 0; i < routes.count; i++) {
        CLLocation* location = [routes objectAtIndex:i];
        CGPoint point = [mapView convertCoordinate:location.coordinate toPointToView:routeView];

        if (i == 0)
            CGContextMoveToPoint(context, point.x, routeView.frame.size.height - point.y);
        else
            CGContextAddLineToPoint(context, point.x, routeView.frame.size.height - point.y);
    }

    CGContextStrokePath(context);

    // this is the point I want to check if it is inside the path
    CLLocationCoordinate2D checkedLocation;
    checkedLocation.latitude = 37.782756;
    checkedLocation.longitude =  -122.409647;
    CGPoint checkedPoint = [mapView convertCoordinate:checkedLocation toPointToView:routeView];
    checkedPoint.y = routeView.frame.size.height - checkedPoint.y;

    // even if the checkedPoint is inside the path, the result is false    
    BOOL checking = CGContextPathContainsPoint(context, checkedPoint, kCGPathStroke);
    if (checking)
        NSLog(@"YES");
    else
        NSLog(@"NO");

    CGImageRef image = CGBitmapContextCreateImage(context);
    UIImage* img = [UIImage imageWithCGImage:image];

    routeView.image = img;
    CGContextRelease(context);
}
  • 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-02T06:36:31+00:00Added an answer on June 2, 2026 at 6:36 am

    Call CGContextStrokePath(context) AFTER you check for your point. Quartz will clear the current path once it’s struck.

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

Sidebar

Related Questions

I have a problem when call applet method from javascript.. I used this function
I have used this function to convert string to bits. def a2bits(chars): return bin(reduce(lambda
In my project i used this below function public function createIconMenu():NativeMenu{ var iconMenu:NativeMenu =
I have used Javascript onlaod like this: function check() { var pic = new
I used this code for sending and returning result. <script type=text/javascript> $(document).ready(function() { $('.special').click(function(){
I want to use this function: http://www.frankmacdonald.co.uk/php/post-to-wordpress-with-php.html Its used to post to Wordpress using
I'm trying to remove the eval statement in this function. I'm used to the
I used a code: jQuery.fn.MyFunction = function(){ return this.each(function() { attributes = test; return
I used the method $(#dvTheatres a).hover(function (){ $(this).css(text-decoration, underline); },function(){ $(this).css(text-decoration, none); } );
I used to use this script for jquery email obfuscation: $(.replaceAt).replaceWith(@); $(.obfuscate).each(function () {

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.