Click or drag to resize

Creating a Route

Verizon Connect Logo
Print this page
Learn more about Verizon Connect GeoBase.
Get information about the latest release

This section of the tutorial describes how to create a simple route from a number of given locations. The location may be given either as a LatLon (latitude/longitude) coordinate pair or as a street address.

Creating the Route

In GeoBase a route is defined by a series of RouteStop objects. These objects would usually be created by a web form or through user input, but for this example we will hard-code the stops.

The following code fragment creates a Route between four different RouteStop objects. Note that a stop can be created from a latitude/longitude pair or a street address.

/* Create stops */
RouteStop Home = new RouteStop(new LatLon(34.1018, -118.2973));
RouteStop Cinema = new RouteStop(GeoCoder.GeoCode("1414 North Azusa Avenue, Covina, CA", Country.USA)[0].Location);
RouteStop Mall = new RouteStop(GeoCoder.GeoCode("112 Plaza Drive, West Covina, CA", Country.USA)[0].Location);
RouteStop Restaurant = new RouteStop(new LatLon(34.0720, -117.4962));
/* ^^ 10100 Banana Ave, Fontana, CA. */

/* Create a route */
Route myRoute = new Route();

/* Add stops to route - note that order is maintained using the AddStops() method with an array */
myRoute.AddStops(new RouteStop[] {Mall, Cinema, Home, Restaurant});
Optimization and Directions

Now that the route has been created we can:

The route and direction data are rendered onto a map shown below.

Next Topic