Type some place names, or click the map to set start and end coordinates.
Directions between two locations can be shown. Locations may be entered as lat,lng pairs or as addresses or place names.
The resulting route is shown on the map, and (optionally) the directions in human-readable form are listed in another region. The total distance (in metres) and duration (in seconds) can be set on a page item you specify. This is done by a dynamic action on the Travel Mode, Origin and Destination items that uses the JK64 Report Google Map R1 Show Directions plugin.
Alternatively, it's possible to achieve the same effect with javascript, e.g.:
$("#map_mymap").reportmap("showDirections",
$v("P7_ORIGIN"),
$v("P7_DEST"),
$v("P7_TRAVEL_MODE"));
After the directions have been received, the map triggers the "directions" event which is used to set the total distance (in metres) and duration (in seconds).
$s("P7_DISTANCE",this.data.distance);
$s("P7_DURATION",this.data.duration);
Subsequent dynamic actions convert these results to kilometres and minutes.
The Directions Panel is an ordinary APEX region with the following contents:
<div id="directionspanel"></div>
The JavaScript Initialization Code on the plugin is:
this.options.directionsPanel = "directionspanel";
Have a peek in your browser console log; you will find the complete output of the DirectionsResponse, a javascript object which includes all details of the route and turn-by-turn instructions.
If you click the map, a dynamic action is triggered ("mapClick") which executes the following:
if ($v("P7_ORIGIN")=="") {
$s("P7_ORIGIN", this.data.lat+","+this.data.lng);
} else {
$s("P7_DEST", this.data.lat+","+this.data.lng);
}