The Map SDK allows you to add different shapes on a map, including the polyline, polygon, and circle.

An HPolylineView object consists of several CLLocationCoordinate2D objects.
- (void)viewDidLoad {
[super viewDidLoad];
/* Polyline. */
CLLocationCoordinate2D polylineCoords[4];
polylineCoords[0].latitude = 48.593478;
polylineCoords[0].longitude = 2.534595;
polylineCoords[1].latitude = 48.593478;
polylineCoords[1].longitude = 2.334595;
polylineCoords[2].latitude = 48.693478;
polylineCoords[2].longitude = 2.334595;
polylineCoords[3].latitude = 48.693478;
polylineCoords[3].longitude = 2.134595;
HPolyline *polyline = [HPolyline polylineWithCoordinates:polylineCoords count:4];
[self.mapView addOverlay:polyline];
}
- (HOverlayView *)mapView:(HMapView *)mapView viewForOverlay:(id<HOverlay>)overlay
{
if ([overlay isKindOfClass:[HPolyline class]])
{
HPolylineView *polylineView = [[HPolylineView alloc] initWithPolyline:overlay];
polylineView.lineWidth = 5;
polylineView.strokeColor = [UIColor redColor];
polylineView.fillColor = [UIColor blackColor];
return polylineView;
}
return nil;
} // Set that the polyline can be tapped. polylineView.isClickable = YES; // Configure the tap callback. - (void) mapView:(HMapView *)mapView didAddOverlayViews:(NSArray *)overlayViews;
Similar to an HPolyline object, an HPolygon object consists of a group of ordered coordinates. However, a polygon is a closed area.
- (void)viewDidLoad {
[super viewDidLoad];
/* Polygon. */
CLLocationCoordinate2D coordinates[4];
coordinates[0].latitude = 48.993478;
coordinates[0].longitude = 2.134595;
coordinates[1].latitude = 48.993478;
coordinates[1].longitude = 2.534595;
coordinates[2].latitude = 48.793478;
coordinates[2].longitude = 2.534595;
coordinates[3].latitude = 48.793478;
coordinates[3].longitude = 2.134595;
HPolygon *polygon = [[HPolygon alloc] initWithWithCoordinates:coordinates count:4];
[self.mapView addOverlay:polygon];
}
- (HOverlayView *)mapView:(HMapView *)mapView viewForOverlay:(id<HOverlay>)overlay
{
if ([overlay isKindOfClass:[HPolygon class]])
{
HPolygonView *polygonView = [[HPolygonView alloc] initWithPolygon:overlay];
polygonView.lineWidth = 3;
polygonView.strokeColor = [UIColor colorWithRed:.2 green:.1 blue:.1 alpha:.8];
polygonView.fillColor = [[UIColor redColor] colorWithAlphaComponent:0.2];
return polygonView;
}
return nil;
} // Set that the polygon can be tapped. polygonView.isClickable = YES; // Configure the tap callback. - (void) mapView:(HMapView *)mapView didAddOverlayViews:(NSArray *)overlayViews;
There are two types of circles: solid circle and hollow circle. By default, a circle is hollow. You can control the circle type using circle attributes.
- (void)viewDidLoad {
[super viewDidLoad];
/* Circle. */
HCircle *circle = [HCircle circleWithCenterCoordinate:CLLocationCoordinate2DMake(48.693478, 2.434595) radius:4000];
[self.mapView addOverlay:circle];
}
- (HOverlayView *)mapView:(HMapView *)mapView viewForOverlay:(id<HOverlay>)overlay
{
if ([overlay isKindOfClass:[HCircle class]])
{
HCircleView *circleView = [[HCircleView alloc] initWithCircle:overlay];
circleView.lineWidth = 3;
circleView.strokeColor = [UIColor blueColor];
circleView.fillColor = [UIColor greenColor];
return circleView;
}
return nil;
} circleView.isClickable = YES; - (void) mapView:(HMapView *)mapView didAddOverlayViews:(NSArray *)overlayViews;
// Set the line width. circleView.lineWidth = 3; // Set the stroke color. circleView.strokeColor = [UIColor blueColor]; // Set the fill color. circleView.fillColor = [UIColor clearColor];
HPolygonView allows you to set the line pattern to one of the following: HOverlayStrokeType_Default, HOverlayStrokeType_Dash, and HOverlayStrokeType_Dot.
HPolygonView: polygonView.lineType = HOverlayStrokeType_Default;