The core component of Navmii SDK responsible for visualization of route-related data visualization is NMRouteVisualizer. This class provides the API to render routes, alternative routes and waypoint markers on map.
CREATING ROUTE VISUALIZER
NMSdk class contains the routeVisualizer
property which allows Navmii SDK user to access providing access to the instance of route visualizer instance. The route visualizer instance can be accessed only be created after the SDK was started.
VISUALIZING THE DATA
NMRouteVisualizer class has the performRequest:request
method method which allows user to execute a route-related data visualization request. The specified request parameter contains data to visualize.
...
NMRouteVisualizerRequest can be configured to perform next the following actions:
- Set or clear the single active route poly-line to render set or remove an active route (active route poly-line polyline is rendered with route color and traffic is displayed on it);
- Set set or clear remove any number of alternative routes (alternative routes are rendered with grey color and traffic is displayed on it);
- Set set or clear remove route way-point waypoint markers, including special markers for start and finish points.
...
Navmii SDK contains NMRouteVisualizerRequestBuilder class which should be used to create immutable NMRouteVisualizerRequest class instances instances configured to render required data on map.
Default initialized builder creates If you call the build
method immediately after creating a builder instance, the returned request which is in this case configured to do nothing with route visualizer state, which means such request, if performed, will not affect the route visualizer state. If route visualizer was previously configured, for example, previously configured to render the a route, nothing will change after such no-op request is executed.
As you can see from NMRouteVisualizerRequestBuilder class interface, the builder allows SDK user to construct the the interface of NMRouteVisualizerRequestBuilder class, it allows to construct a request which performs multiple operations (i.e. to set an active route, to set one or multiple alternative routes and to set way-point markers) within the single request. This is the preferred way of handing to handle the visualizer state in terms of performance as each route visualizer request, once executed, requires map tiles to be re-created.
Tip |
---|
If possible, try to create the a single request configured to perform all the required actions rather then than creating multiple a new request for each action. The less times NMRouteVisualizer class often the |
VISUALIZING ROUTES
NMRouteVisualizerRequestBuilder class has the setRoutePolylineFromsetRoutePolylineFromRoute:route
method method which allows SDK user to render the active route poly-line polyline on map. The route
parameter is the an instance of NMRoute class which poly-line should be renderedis used to get polyline to render. Active route poly-line polyline is rendered with route color and traffic . Traffic is displayed on route poly-line polyline if the route contains it.
setRoutePolylineAndWaypointMarkersFromThe setRoutePolylineAndWaypointMarkersFromRoute:route
method method allows SDK user to render the active route poly-line polyline along with its way-points waypoints on the map. The route
parameter is the an instance of NMRoute class which is used to get poly-line polyline and route plan from. Special start point marker (blue flag) is used for route origin, special finish point marker (black-and-white flag) is used for route destination destination, intermediate way-points waypoints are rendered with way-points markers ( yellow flag).
setAlternativeRoutePolylinesFromThe setAlternativeRoutePolylinesFromRoutes:routes
method method allows SDK user to render alternative route poly-lines polylines on map. The routes
parameter is the list an array of alternative routes represented by . Each route is an instance of NMRoute class instances which poly-lines should be rendered on map. Alternative route which is used to get polyline to render. Alternative routes are rendered with grey color and traffic is displayed on each poly-line polyline if route contains it.
The clearRoutePolyline
and clearAlternativeRoutePolylines
method allows SDK user to clear active or alternative route poly-lines methods allow to remove the active and the alternative route polylines respectively.
VISUALIZING
...
WAYPOINT MARKERS
NMRouteVisualizerRequestBuilder has the setWaypointMarkersAtsetWaypointMarkersAtCoordinates:coordinates consideringFirstOneAsStart:considerFirstOneAsStart
method method which allows SDK user to render way-point waypoint markers on map. coordinates
is the list of way-point markers coordinates represented by NMMapCoordinates class instances. Special The coordinates
parameter specifies an array of waypoint marker coordinates. Each coordinate is an instance of NMMapCoordinates class. The special finish marker (black-and-white flag) is always used for the last way-point. Regular way-point markers (yellow flag) are used for the rest way-point except for the first one. Whether regular way-point waypoint. The special start marker (blue flag) is used for the first waypoint if YES is specified for the consideringFirstOneAsStart
parameter, otherwise the regular waypoint marker (yellow flag) or special start marker (blue flag) will be used for the first way-point depends on considerFirstOneAsStart
parameter (special start marker if YES
and regular way-point marker if NO
).clearWaypointMarkers
method allows SDK user to clear way-point is used. The regular marker is also used for all other waypoints.
The clearWaypointMarkers
method allows to clear waypoint markers on map.
ROUTE VISUALIZER BINDING
NMRouteVisualizer class conforms to the NMRouteVisualizerRequestListener protocol which allows SDK user to bind it to route visualizer request source. The only source of route visualizer request in Navmii SDK is NMRouteNavigator class which automatically renders route being navigated on the map. You are able to implement your own route visualizer request source if you need to.
...