How Can I Draw A Radius Around A Map Marker Using Google Maps SDK (Swift/iOS)?
Here is swift code to draw circle on specified radius in mile
let circleCenter : CLLocationCoordinate2D = CLLocationCoordinate2DMake(centerLattitude, centerLongitude);
let circ = GMSCircle(position: circleCenter, radius: distanceInMile * 1609.34)
circ.fillColor = UIColor(red: 0.0, green: 0.7, blue: 0, alpha: 0.1)
circ.strokeColor = UIColor(red: 255/255, green: 153/255, blue: 51/255, alpha: 0.5)
circ.strokeWidth = 2.5;
circ.map = self.googleMapView;
This is kind of three separate questions, but anyway:
1.
The GMSMarker
is always drawn at the same size (in pixels), regardless of the map scale. For an image which scales with the map, have a look at GMSGroundOverlay
.
2.
You've defined the radius as 3000 metres, so it should always be that size in metres, and so scale with the scale of the map. Or did you want it to be a fixed size in pixels, so get bigger in metres as you zoom out?
3.
You'll need to store the circle as a member (like you do with the marker), and update its position every time you move, instead of always create a new circle.