You can specify transit specific routing options through the TransitOptions object literal. Transit directions are time sensitive. Directions will only be returned for times in the future. The TransitOptions object literal contains the following fields:. You can specify routing options for driving directions through the DrivingOptions object. Below is a sample DirectionsRequest for driving directions:. By default, directions are calculated and displayed using the unit system of the origin's country or region.
For example, a route from "Chicago, IL" to "Toronto, ONT" will display results in miles, while the reverse route will display results in kilometers. You can override this unit system by setting one explicitly within the request using one of the following UnitSystem values:. Note: This unit system setting only affects the text displayed to the user. The directions result also contains distance values , not shown to the user, which are always expressed in meters.
If you load the bootstrap from a different supported domain, you will get results influenced by that domain. You can also set the Directions service to return results biased to a particular region using the region parameter. This parameter takes a region code, specified as a IANA language region subtag.
In most cases, these tags map directly to ccTLD "top-level domain" two-character values such as "uk" in "co. Initiating a directions request to the DirectionsService with the route method requires passing a callback which executes upon completion of the service request. This callback will return a DirectionsResult and a DirectionsStatus code in the response.
You should ensure that the directions query returned valid results by checking this value before processing the result. The DirectionsResult contains the result of the directions query, which you may either handle yourself, or pass to a DirectionsRenderer object, which can automatically handle displaying the result on a map.
To display a DirectionsResult using a DirectionsRenderer , you need to do the following:. The following example calculates directions between two locations on Route 66, where the origin and destination are set by the given "start" and "end" values in the dropdown lists.
The DirectionsRenderer handles display of the polyline between the indicated locations, and the placement of markers at the origin, destination, and any waypoints, if applicable.
View example. A DirectionsRenderer not only handles display of the polyline and any associated markers, but also can handle the textual display of directions as a series of steps. Doing so also ensures that you display the appropriate copyright information, and any warnings which may be associated with the result.
Textual directions will be provided using the browser's preferred language setting, or the language specified when loading the API JavaScript using the language parameter. For more information, see Localization. In the case of transit directions, the time will be displayed in the time zone at that transit stop.
When sending a directions request to the DirectionsService , you receive a response consisting of a status code, and a result, which is a DirectionsResult object. The DirectionsResult is an object literal with the following fields:. Version 3. For versions 3.
Only the main route should be draggable. Users can drag the main route until it matches an alternative route. A DirectionsGeocodedWaypoint contains details about the geocoding of origin, destination and waypoints. The DirectionsGeocodedWaypoint is an object literal with the following fields:.
Partial matches most often occur for street addresses that do not exist within the locality you pass in the request. The API returns the most efficient routes when calculating directions. Travel time is the primary factor optimized, but the API may also take into account other factors such as distance, number of turns and many more when deciding which route is the most efficient.
To learn more, see Set up in Cloud Console. Note : URLs must be properly encoded to be valid and are limited to characters for all web services. Be aware of this limit when constructing your URLs. The list of parameters and their possible values are enumerated below. The options for the destination parameter are the same as for the origin parameter.
This coordinate may be different from that returned by the Geocoding API, for example a building entrance rather than its center. Using coordinates will always result in the point being snapped to the road nearest to those coordinates - which may not be an access point to the property, or even a road that will quickly or safely lead to the destination.
If you pass coordinates, the point will snap to the nearest road. Passing a place ID is preferred. If you do pass coordinates, ensure that no space exists between the latitude and longitude values. Plus codes must be formatted as a global code or a compound code.
If set to true , specifies that the Directions service may provide more than one route alternative in the response. Note that providing route alternatives may increase the response time from the server. This is only available for requests without intermediate waypoints. For more information, see the guide to waypoints. Specifies the desired time of arrival for transit directions, in seconds since midnight, January 1, UTC. Indicates that the calculated route s should avoid the indicated features.
This parameter supports the following arguments:. It's possible to request a route that avoids any combination of tolls, highways and ferries by passing multiple restrictions to the avoid parameter. For example:. Specifies the desired time of departure. You can specify the time as an integer in seconds since midnight, January 1, UTC.
Alternatively, you can specify a value of now, which sets the departure time to the current time correct to the nearest second. The departure time may be specified in two cases:. For the calculation of distances and directions, you may specify the transportation mode to use. By default, directions are calculated as driving directions. The following travel modes are supported:.
The region code, specified as a ccTLD "top-level domain" two-character value. Specifies the assumptions to use when calculating time in traffic. The available values for this parameter are:. Specifies one or more preferred modes of transit. This parameter may only be specified for transit directions. The parameter supports the following arguments:.
Specifies preferences for transit routes. Using this parameter, you can bias the options returned, rather than accepting the default best route chosen by the API. Directions results contain text within distance fields that may be displayed to the user to indicate the distance of a particular "step" of the route. By default, this text uses the unit system of the origin's country or region. For example, a route from "Chicago, IL" to "Toronto, ONT" will display results in miles, while the reverse route will display results in kilometers.
You may override this unit system by setting one explicitly within the request's units parameter, passing one of the following values:. Specifies an array of intermediate locations to include along the route between the origin and destination points as pass through or stopover locations. Waypoints alter a route by directing it through the specified location s.
The API supports waypoints for these travel modes: driving, walking and bicycling; not transit. By default, the Directions service calculates a route using the waypoints in the order they are given. For each waypoint in the request, the directions response appends an entry to the legs array to provide the details for stopovers on that leg of the journey.
If you'd like to influence the route using waypoints without adding a stopover, add the prefix via: to the waypoint. Waypoints prefixed with via: will not add an entry to the legs array, but will route the journey through the waypoint.
The following URL modifies the previous request such that the journey is routed through Lexington without stopping:.
The via: prefix is most effective when creating routes in response to the user dragging the waypoints on the map. Doing so allows the user to see how the final route may look in real-time and helps ensure that waypoints are placed in locations that are accessible to the Directions API.
By default, the Directions service calculates a route through the provided waypoints in their given order. Optionally, you may pass optimize:true as the first argument within the waypoints parameter to allow the Directions service to optimize the provided route by rearranging the waypoints in a more efficient order. This optimization is an application of the traveling salesperson problem.
Travel time is the primary factor which is optimized, but other factors such as distance, number of turns and many more may be taken into account when deciding which route is the most efficient.
All waypoints must be stopovers for the Directions service to optimize their route. The following example calculates a road journey from Adelaide, South Australia to each of South Australia's main wine regions using route optimization.
Inspection of the calculated route will indicate that calculation uses waypoints in the following waypoint order:. Generated from the OpenAPI specification. NewRequest method, url, nil if err! Do req if err! ReadAll res. Body if err! By changing the mode and avoid parameters, the initial request can be modified to return directions for a scenic bicycle journey that avoids major highways.
Note: In this example the departure time is specified as July 30, at am. To avoid an error, you must change the parameter to a time in the future before submitting the request. When you calculate directions, you may specify the transportation mode to use. Note: Both walking and bicycling directions may sometimes not include clear pedestrian or bicycling paths, so these directions will return warnings in the returned result which you must display to the user.
When calculating routes using the Directions API, you may specify waypoints to return a route that includes pass throughs or stopovers at intermediate locations. You can add waypoints to driving, walking or bicycling directions but not transit directions.
For efficiency and accuracy, use place ID's when possible. Unlike an address, ID's do not require the service to perform a search or an intermediate request for place details; therefore, performance is better. Alternatively, you can supply an encoded set of points using the Encoded Polyline Algorithm. You will find an encoded set is useful for a large number of waypoints, because the URL is significantly shorter.
All web services have a URL limit of characters. The example uses addresses:. Note that you can freely intermix a via: specifier with location modifiers. Directions may be calculated that adhere to certain restrictions. Restrictions are indicated by use of the avoid parameter, and an argument to that parameter indicating the restriction to avoid.
The following restrictions are supported:. It's possible to request a route that avoids any combination of tolls, highways and ferries by passing both restrictions to the avoid parameter. Note: the addition of restrictions does not preclude routes that include the restricted feature; it biases the result to more favorable routes.
Note: this unit system setting only affects the text displayed within distance fields. The distance fields also contain values which are always expressed in meters. You can set the Directions service to return results from a specific region by using the region parameter. This parameter takes a ccTLD country code top-level domain argument specifying the region bias. You may utilize any domain in which the main Google Maps application has launched driving directions. For example, a directions request for "Toledo" to "Madrid" returns appropriate results when region is set to es and "Toledo" is then interpreted as the Spanish city:.
A directions request for "Toledo" to "Madrid" sent without a region parameter does not return results, because "Toledo" is interpreted as the city in Ohio and not Spain:.
These modifiers may be freely mixed with the via: modifier for intermediate waypoints. Skip to content. Twitter Facebook Pinterest Google Classroom. Links map The Weather Channel: U. Current Weather. Prepare materials for the activity. Find east and west by observing the sun in the morning and afternoon. Observe north and south, and label the classroom walls.
Add the north and south labels to the classroom walls: Use a compass, or a compass app on a smartphone or tablet, to show north and south and reinforce east and west. Have students line up the E and W on the compass with east and west labeled on the wall. Ask them to point toward the N, and explain that this direction is north.
In areas where there is snow, teach north and south by observing where snow melts faster: the south side of buildings in the northern hemisphere. North and south can also be observed with wind patterns. Track the weather using the provided Weather Channel website, and look for opportunities to take the students outside when north or south winds are blowing. Practice using cardinal direction s. Have students apply their understanding to a map. Extending the Learning Have students watch the sun over a matter of months and note the change in its location as the days shorten and lengthen.
Move the familiar animal to a different spot in the room each day. Have students write the location of the animal using cardinal directions. Over time this could be expanded to other locations in the school or playground where N, S, E, and W are labeled.
Show students the variety of ways that maps show the cardinal directions. On local, state, or country maps, look for the compass rose or the north arrow. Help students determine which way north, south, east and west are on those maps.
Place the maps flat on a surface to reinforce the true directions. Learning Objectives Students will: describe the pattern of the location of the sun each morning and afternoon and connect this to the directions east and west name the cardinal directions and point toward north, south, east, and west using signs in their classroom use north, south, east, and west when describing locations of items on a map. Teaching Approach Learning-for-use.
Teaching Methods Discussions Modeling Visual instruction. Resources Provided The resources are also available at the top of the page.
So in the morning, the sun will be in the east; in the afternoon, it will be in the west. At night, the North Star in the Northern Hemisphere points north. The Southern Cross , which is a constellation , or group of stars, marks south in the Southern Hemisphere. The arrow is a universal symbol for direction. If someone needs to turn right at a stop sign to get to the freeway , there will usually be an arrow pointing the way.
Photograph by Mel Garrett , My Shot. A simple compass can be made by floating a magnetized needle on a leaf in a dish of water. You can magnetize a needle by rubbing it with silk or a magnet. The audio, illustrations, photos, and videos are credited beneath the media asset, except for promotional images, which generally link to another page that contains the media credit.
The Rights Holder for media is the person or group credited. Caryl-Sue, National Geographic Society. Dunn, Margery G. For information on user permissions, please read our Terms of Service. If you have questions about how to cite anything on our website in your project or classroom presentation, please contact your teacher. They will best know the preferred format.
0コメント