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

送分小仙女□ 提交于 2020-01-01 20:06:23

问题


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


回答1:


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;
    }
}


来源:https://stackoverflow.com/questions/24750037/how-to-show-markers-only-in-gmscircle-region-otherwise-hide-in-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!