THIS SDK ISDEPRECATED.

We rolled out a new and better SDK for you.

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 render circles around cities with radiuses indicating zones of deliveries. The details on the example implementation of shapes rendering follows.

The TomtomMap supports several shape overlays which can be easily created by using corresponding overlay builders. These are:

  • PolygonBuilder
  • PolylineBuilder
  • CircleBuilder

Shape overlays are immutable. That is, once they have been created their shape cannot be changed. Visibility and color can be changed. 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 take care of performance and the number of shapes in use. You should use as few shapes as possible, and hide or dispose of the ones that are not being displayed.

To create shape overlays:

1Polygon polygon = PolygonBuilder.create()
2 .coordinates(coordinates)
3 .color(color)
4 .build()
5
6tomtomMap.getOverlaySettings().addOverlay(polygon);
1val polygon = PolygonBuilder.create()
2 .coordinates(coordinates)
3 .color(color)
4 .build()
5
6tomtomMap.overlaySettings.addOverlay(polygon)
1Polyline polyline = PolylineBuilder.create()
2 .coordinates(coordinates)
3 .color(color)
4 .build();
5
6tomtomMap.getOverlaySettings().addOverlay(polyline);
1val polyline = PolylineBuilder.create()
2 .coordinates(coordinates)
3 .color(color)
4 .build()
5
6tomtomMap.overlaySettings.addOverlay(polyline)
1Circle circle = CircleBuilder.create()
2 .fill(true)
3 .radius(radiusM)
4 .position(position)
5 .color(color)
6 .build();
7
8tomtomMap.getOverlaySettings().addOverlay(circle);
1val circle = CircleBuilder.create()
2 .fill(true)
3 .radius(CIRCLE_RADIUS_IN_METERS)
4 .position(position)
5 .color(color)
6 .build()
7
8tomtomMap.overlaySettings.addOverlay(circle)

To register click events:

1tomtomMap.addOnCircleClickListener(onCircleClickListener);
2tomtomMap.addOnPolygonClickListener(onPolygonClickListener);
3tomtomMap.addOnPolylineClickListener(onPolylineClickListener);
1tomtomMap.addOnCircleClickListener { infoTextView.displayAsToast(getString(R.string.toast_circle_clicked)) }
2tomtomMap.addOnPolygonClickListener { infoTextView.displayAsToast(getString(R.string.toast_polygon_clicked)) }
3tomtomMap.addOnPolylineClickListener { infoTextView.displayAsToast(getString(R.string.toast_polyline_clicked)) }

To unregister click events:

1tomtomMap.removeOnCircleClickListeners();
2tomtomMap.removeOnPolygonClickListeners();
3tomtomMap.removeOnPolylineClickListeners();
1tomtomMap.removeOnCircleClickListeners()
2tomtomMap.removeOnPolygonClickListeners()
3tomtomMap.removeOnPolylineClickListeners()

image

Polygon overlay

image

Polyline overlay

image

Circle overlay