Search code examples
iosgoogle-mapsgmsmapview

how to show markers only in gmscircle region otherwise hide in ios


how to show markers only in GMSCirle region otherwise hide in iOS , I have created GMSCirle using google maps, now I wanna display markers only on the region of GMSCirle otherwise hide markers.

here is my code :

GMSMarker *centerPoint=[GMSMarker markerWithPosition:CLLocationCoordinate2DMake(16.301687, 80.419235)];
    centerPoint.icon=[UIImage imageNamed:@"PinImage.png"];

    circ.fillColor = [UIColor colorWithRed:0.25 green:0 blue:0 alpha:0.05];
    circ.strokeColor = [UIColor blackColor];
    circ.strokeWidth = 5;
    circ.tappable=true;
    circ.map = mapView_;
    mapView_.settings.myLocationButton=YES;
    mapView_.settings.zoomGestures=YES;
    mapView_.settings.zoomGestures=YES;
    mapView_.settings.compassButton=YES;
    mapView_.settings.rotateGestures=YES;
    mapView_.settings.scrollGestures=YES;
    mapView_.settings.tiltGestures=YES;
    mapView_.myLocationEnabled=YES;

I struggled a lot if any idea would be appreciable , Thanks in advance.

Simply i just wanna know how to display markers only on particular region in iOS


Solution

  • You can use following simple idea for it.

    -(BOOL) checkMarker:(CLLocation*)locB
    
    {
    CLLocation *locA = [[CLLocation alloc]
                        initWithLatitude:24.590095
                        longitude:73.698256];
    
    CLLocationDistance distance = [locA distanceFromLocation:locB];
    NSLog(@"%f",distance);
    
    if(distance <= RADIUS)
    {
        NSLog(@"You are in Circle ");
        return true;
    }
    else
    {
        NSLog(@"You are not in circle");
        return false;
        }
    }