JavaScript

mapControl.plotRoute Method

Google imposes a limit on the number of items in the route based on the service you have contracted with Google. If your route does not plot, try reducing the number of items in the route.

Syntax

mapObj.plotRoute(location1, location2 [,...locationN]);

mapObj.plotRoute(locationArray);

Arguments

location1stringarray

The first location, specified as an address or an array containing latitude/longitude values, to include in the route.

location2stringarray

The second location, specified as an address or an array containing latitude/longitude values, to include the route.

locationNstringarray

Additional location(s), specified as an address or an array containing latitude/longitude values, to include in the route. You can specify as many additional locations as you want provided your Google Maps service allows the additional locations to be included. See warning.

locationArrayarray

An array of locations, specified as an address or an array containing latitude/longitude values.

Description

Plots a route on a Map Control through at least two locations.

Discussion

Each location in the route can be an address or an array with latitude/longitude values. You can optionally pass in an array of locations. Each item in the array is either an address string or latitude/longitude value.

Example

//get a pointer to the map control for variable 'mymap1'
var mapObj = {dialog.object}.getControl('mymap1');

if (mapObj) {
    // plot a route. note that some locations are in the form of addresses, while others are lat/lng values
    mapObj.plotRoute('70 Blanchard Road Burlington, MA',[42.4141,-71.1256],'4 Yawkey Way Boston, MA');

    //In this example, we explicitly set certain route preferences
    var mapObj = {dialog.object}.getControl('mymap1');
    mapObj.route.travelMode = 'driving';
    mapObj.route.units = 'metric';
    mapObj.route.avoid.highways = false;
    mapObj.route.avoid.tolls = true;
    mapObj.route.optimizeOrder = true;
    mapObj.plotRoute('70 Blanchard Road Burlington, MA',[42.4141,-71.1256],'4 Yakey Way Boston, MA');
}