This example app demonstrates the following features:
- Generate a number of polygon territories from a list of coordinates and display them on the map.
To generate one territory, minimum 3 coordinates are needed; remember that the number of coordinates should be at least 3 times the number of territories that you want to create. If the number of territories to be created is not specified, the algorithm will determinate how many should be created.
When having many locations to visit, it is better if first you divide them by territories and after you can create optimizations with the customers from each territory.
When you run the example app, a list of territories will be returned and showed on map.
- Create a
CoordinatesListand add all theCoordinates. - Create a
ProgressListener,vrp::Serviceandvrp::Territorylist, in which the territories will be returned. - Call the
generateTerritories()method fromvrp::Serviceusing the lists from 2.) and 1., specify the number of territories that you want to create and the progress listener. - Once the operation completes, the list from 2.) will contain the generated territories.
- Create a
MapServiceListener,OpenGLContextandMapView. - Create a
MarkerCollectionof type Point and addCoordinatesListfrom above. - Create a
MarkerCollectionDisplaySettingsand set thepointsGroupingZoomLevelto0, to not group the points on the map. - Set the newly created
MarkerCollectionin the markers collections of the map view preferences, together with theMarkerCollectionDisplaySettings. - Instruct the
MapViewto center on theMarkerCollection's area. - For each territory create a
MarkerCollectionand aMarkerCollectionDisplaySettings. In theMarkerCollectionadd the data of the territory and in theMarkerCollectionDisplaySettingsset the territory's color to thepolygonFillColor. - Set the all the newly created
MarkerCollectionin the markers collections of the map view preferences, together with theMarkerCollectionDisplaySettings. - Allow the application to run until the map view is fully loaded.

