Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to draw circle using Google Maps SDK for iOS?

I am really confused with this issue. I want to draw circle on google map in my iOS app. In SDK help provide examples for polygons only. Anyone have the same problem?

like image 205
hex Avatar asked Dec 26 '22 07:12

hex


2 Answers

I have no idea why you are noted down because I have the same problem. After many research, and the Saxon Druce's answer, I've seen the Circle on Android SDK but not in iOS.

--- EDIT ---

There are 2 solutions here : How to display a circle in GMSMapView

--- EDIT 2 ----

Since his version 1.2.1 (23 April 2013), Google Maps SDK for iOS count a GMSCircle in his Shapes.

Now you can draw like this :

CLLocationCoordinate2D circleCenter = CLLocationCoordinate2DMake(37.35, -122.0);
GMSCircle *circ = [GMSCircle circleWithPosition:circleCenter
                                         radius:1000];

circ.fillColor = [UIColor colorWithRed:0.25 green:0 blue:0 alpha:0.05];
circ.strokeColor = [UIColor redColor];
circ.strokeWidth = 5;
circ.map = mapView;

source here

like image 57
Thomas Leduc Avatar answered Jan 17 '23 11:01

Thomas Leduc


At the moment the SDK doesn't support circles, but there is a feature request to add circles here:

https://code.google.com/p/gmaps-api-issues/issues/detail?id=4971

In the meantime you could maybe fake a circle by drawing a polyline, with several short segments?

like image 24
Saxon Druce Avatar answered Jan 17 '23 10:01

Saxon Druce