Sorry, you need to enable JavaScript to visit this website.

Shapes

Shapes

Allow your users to draw shapes like circles, polygons and polylines on your map to mark different areas on the map.

Sample use case: You are developing an app for a delivery company and need to illustrate ranges of the transportation area around different cities.
What you need to do is e.g. to render circles round cities with radiuses indicating zones of deliveries.
The details on the example implementation of shapes rendering are described below.

A TTMapView supports several shape overlays. These are:

  • TTCircle

  • TTPolygon

  • TTPolyline

Shape overlays are immutable i.e. once they have been created, their shapes cannot be changed (although you may change their visibility and color).
If you want to change a shape, you must remove the existing shape and replace it with a new one.

It is the responsibility of the framework user to be conscientious about performance and how many shape overlays they are using.
You should use as few shapes as possible, and hide or dispose of ones that are not being displayed.

Code examples are below:

TTPolygon *polygon = [TTPolygon polygonWithCoordinates:coordinates count:POLYLINE_POINTS opacity:1.0 color:color colorOutline:color];
[self.mapView.annotationManager addOverlay:polygon];

 

TTPolyline *polyline = [TTPolyline polylineWithCoordinates:coordinates count:(NSUInteger) (POLYLINE_POINTS / 1.5) opacity:(float) 1.0 width:(float) 8.0 color:color];
[self.mapView.annotationManager addOverlay:polyline];

 

TTCircle *circle = [TTCircle circleWithCenterCoordinate:centroid radius:5000 width:10.0 color:color fill:true colorOutlet:[UIColor redColor]];
[self.mapView.annotationManager addOverlay:circle];

 



image

Circle

image

Polygon

image

Polyline

Click delegate

You can implement an observable of shape clicked event. You can do that with the global delegate TTAnnotationDelegate
for all shapes that has to be registered on TTAnnotationManager as following

Maps SDK allows to observe shape selected event.
There is one global delegate TTAnnotationDelegate for all shapes that has to be registered on TTAnnotationManager as followed.

self.mapView.annotationManager.delegate = self;
- (void)annotationManager:(id<TTAnnotationManager>)annotationManager touchUpPolyline:(TTPolyline *)polyline {
}
- (void)annotationManager:(id<TTAnnotationManager>)annotationManager touchUpPolygon:(TTPolygon *)polygon {
}
- (void)annotationManager:(id<TTAnnotationManager>)annotationManager touchUpCircle:(TTCircle *)circle {