Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

The core component of Navmii SDK responsible for visualization of route-related data 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 providing access to the instance of route visualizer. The route visualizer instance can be accessed only after the SDK was started.

VISUALIZING THE DATA

NMRouteVisualizer class has the performRequest: method which allows to execute a route-related data visualization request. The specified request parameter contains data to visualize.

Note that visualization request, once performed, affects global SDK state, therefore it's user's responsibility to handle the state correctly.

Route visualization request is the instance of NMRouteVisualizerRequest class.

NMRouteVisualizerRequest can be configured to perform the following actions:

  • set or remove an active route (active route polyline is rendered with route color and traffic is displayed on it);
  • set or remove any number of alternative routes (alternative routes are rendered with grey color and traffic is displayed on it);
  • set or remove route waypoint markers, including special markers for start and finish points.

CREATING ROUTE VISUALIZATION REQUEST

Navmii SDK contains NMRouteVisualizerRequestBuilder class which should be used to create immutable NMRouteVisualizerRequest instances configured to render required data on map.

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, to render a route, nothing will change after such no-op request is executed.

As you can see from 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 to handle the visualizer state in terms of performance as each route visualizer request, once executed, requires map tiles to be re-created.

If possible, try to create a single request configured to perform all the required actions rather than creating a new request for each action. The less often the performRequest: method of NMRouteVisualizer is called, the better.

VISUALIZING ROUTES

NMRouteVisualizerRequestBuilder class has the setRoutePolylineFromRoute: method which allows to render the active route polyline on map. The route parameter is an instance of NMRoute class which is used to get polyline to render. Active route polyline is rendered with route color. Traffic is displayed on route polyline if the route contains it.

The setRoutePolylineAndWaypointMarkersFromRoute: method allows to render the active route polyline along with its waypoints on map. The route parameter is an instance of NMRoute class which is used to get 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, intermediate waypoints are rendered with yellow flag.

The setAlternativeRoutePolylinesFromRoutes: method allows to render alternative route polylines on map. The routes parameter is an array of alternative routes. Each route is an instance of NMRoute class which is used to get polyline to render. Alternative routes are rendered with grey color and traffic is displayed on each polyline if route contains it.

The clearRoutePolyline and clearAlternativeRoutePolylines methods allow to remove the active and the alternative route polylines respectively.

VISUALIZING WAYPOINT MARKERS

NMRouteVisualizerRequestBuilder has the setWaypointMarkersAtCoordinates:consideringFirstOneAsStart: method which allows to render waypoint markers on map. 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 used for the last 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) 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 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 map. You are able to implement your own route visualizer request source if you need to.


  • No labels