本文整理汇总了Java中com.google.maps.model.TravelMode类的典型用法代码示例。如果您正苦于以下问题:Java TravelMode类的具体用法?Java TravelMode怎么用?Java TravelMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TravelMode类属于com.google.maps.model包,在下文中一共展示了TravelMode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getDriveDist
import com.google.maps.model.TravelMode; //导入依赖的package包/类
public static long getDriveDist(String addrOne, String addrTwo) throws ApiException, InterruptedException, IOException{
//set up key
GeoApiContext distCalcer = new GeoApiContext.Builder()
.apiKey(API_KEY)
.build();
DistanceMatrixApiRequest req = DistanceMatrixApi.newRequest(distCalcer);
DistanceMatrix result = req.origins(addrOne)
.destinations(addrTwo)
.mode(TravelMode.DRIVING)
.avoid(RouteRestriction.TOLLS)
.language("en-US")
.await();
long distApart = result.rows[0].elements[0].distance.inMeters;
return distApart;
}
开发者ID:Celethor,项目名称:CS360proj1,代码行数:20,代码来源:EarthSearch.java
示例2: distanceMatrix
import com.google.maps.model.TravelMode; //导入依赖的package包/类
public static void distanceMatrix(String[] origins, String[] destinations) throws ApiException, InterruptedException, IOException{
GeoApiContext context = new GeoApiContext.Builder()
.apiKey(API_KEY)
.build();
DistanceMatrixApiRequest req=DistanceMatrixApi.newRequest(context);
DistanceMatrix t=req.origins(origins).destinations(destinations).mode(TravelMode.DRIVING).await();
//long[][] array=new long[origins.length][destinations.length];
File file=new File("Matrix.txt");
FileOutputStream out=new FileOutputStream(file);
DataOutputStream outFile=new DataOutputStream(out);
for(int i=0;i<origins.length;i++){
for(int j=0;j<destinations.length;j++){
//System.out.println(t.rows[i].elements[j].distance.inMeters);
outFile.writeLong(t.rows[i].elements[j].distance.inMeters);
}
}
outFile.close();
}
开发者ID:Celethor,项目名称:CS360proj1,代码行数:20,代码来源:EarthSearch.java
示例3: getDistanceMatrix
import com.google.maps.model.TravelMode; //导入依赖的package包/类
public static DistanceMatrix getDistanceMatrix(boolean driving) {
String[] shipments = new String[1 + ShipmentController.getItems().size()];
shipments[0] = PathController.getWalkingPO().getAddress();
for (int i = 0; i < ShipmentController.getItems().size(); i++) {
shipments[i + 1] = ShipmentController.getItems().get(i).getAddress();
}
GeoApiContext context = new GeoApiContext().setApiKey(XFacteur.GOOGLE_API_KEY);
DistanceMatrixApiRequest req = DistanceMatrixApi.getDistanceMatrix(context, shipments, shipments);
req.language("fr-FR");
req.units(Unit.METRIC);
req.mode(driving ? TravelMode.DRIVING : TravelMode.WALKING);
try {
return req.await();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
开发者ID:teamOtee,项目名称:x-facteur,代码行数:21,代码来源:DistanceMatrixHTTPGetter.java
示例4: getDirections
import com.google.maps.model.TravelMode; //导入依赖的package包/类
public void getDirections() {
this.fromLatLngCurr = fromLatLngNew;
this.toLatLngCurr = toLatLngNew;
this.fromTitleCurr = fromTitleNew;
this.toTitleCurr = toTitleNew;
try {
calculatedRoutes = DirectionsApi.newRequest(context)
.alternatives(true)
.mode(TravelMode.WALKING)
.origin(MapUtils.getModelLatLngFromGms(fromLatLngCurr))
.destination(MapUtils.getModelLatLngFromGms(toLatLngCurr))
.await();
} catch (Exception e) {
e.printStackTrace();
}
clearMarkersFromMap();
drawRouteMarkers();
updateBounds();
}
开发者ID:nogalavi,项目名称:Bikeable,代码行数:25,代码来源:DirectionsManager.java
示例5: validateRequest
import com.google.maps.model.TravelMode; //导入依赖的package包/类
@Override
protected void validateRequest() {
if (!params().containsKey("origin")) {
throw new IllegalArgumentException("Request must contain 'origin'");
}
if (!params().containsKey("destination")) {
throw new IllegalArgumentException("Request must contain 'destination'");
}
if (TravelMode.TRANSIT.toString().equals(params().get("mode"))
&& (params().containsKey("arrival_time") && params().containsKey("departure_time"))) {
throw new IllegalArgumentException(
"Transit request must not contain both a departureTime and an arrivalTime");
}
if (params().containsKey("traffic_model") && !params().containsKey("departure_time")) {
throw new IllegalArgumentException(
"Specifying a traffic model requires that departure time be provided.");
}
}
开发者ID:googlemaps,项目名称:google-maps-services-java,代码行数:19,代码来源:DirectionsApiRequest.java
示例6: testLanguageParameter
import com.google.maps.model.TravelMode; //导入依赖的package包/类
/**
* Test the language parameter.
*
* <p>Sample request: <a
* href="http://maps.googleapis.com/maps/api/distancematrix/json?origins=Vancouver+BC|Seattle&destinations=San+Francisco|Victoria+BC&mode=bicycling&language=fr-FR">
* origins: Vancouver BC|Seattle, destinations: San Francisco|Victoria BC, mode: bicycling,
* language: french</a>.
*/
@Test
public void testLanguageParameter() throws Exception {
try (LocalTestServerContext sc = new LocalTestServerContext("{\"status\" : \"OK\"}")) {
String[] origins = new String[] {"Vancouver BC", "Seattle"};
String[] destinations = new String[] {"San Francisco", "Victoria BC"};
DistanceMatrixApi.newRequest(sc.context)
.origins(origins)
.destinations(destinations)
.mode(TravelMode.BICYCLING)
.language("fr-FR")
.await();
sc.assertParamValue(StringUtils.join(origins, "|"), "origins");
sc.assertParamValue(StringUtils.join(destinations, "|"), "destinations");
sc.assertParamValue(TravelMode.BICYCLING.toUrlValue(), "mode");
sc.assertParamValue("fr-FR", "language");
}
}
开发者ID:googlemaps,项目名称:google-maps-services-java,代码行数:27,代码来源:DistanceMatrixApiTest.java
示例7: testTransitWithoutSpecifyingTime
import com.google.maps.model.TravelMode; //导入依赖的package包/类
/** Test transit without arrival or departure times specified. */
@Test
public void testTransitWithoutSpecifyingTime() throws Exception {
try (LocalTestServerContext sc = new LocalTestServerContext("{\"status\" : \"OK\"}")) {
String[] origins =
new String[] {"Fisherman's Wharf, San Francisco", "Union Square, San Francisco"};
String[] destinations =
new String[] {"Mikkeller Bar, San Francisco", "Moscone Center, San Francisco"};
DistanceMatrixApi.newRequest(sc.context)
.origins(origins)
.destinations(destinations)
.mode(TravelMode.TRANSIT)
.await();
sc.assertParamValue(StringUtils.join(origins, "|"), "origins");
sc.assertParamValue(StringUtils.join(destinations, "|"), "destinations");
sc.assertParamValue(TravelMode.TRANSIT.toUrlValue(), "mode");
}
}
开发者ID:googlemaps,项目名称:google-maps-services-java,代码行数:20,代码来源:DistanceMatrixApiTest.java
示例8: testDurationInTrafficWithTrafficModel
import com.google.maps.model.TravelMode; //导入依赖的package包/类
/** Test duration in traffic with traffic model set. */
@Test
public void testDurationInTrafficWithTrafficModel() throws Exception {
try (LocalTestServerContext sc = new LocalTestServerContext("{\"status\" : \"OK\"}")) {
final long ONE_HOUR_MILLIS = 60 * 60 * 1000;
DistanceMatrixApi.newRequest(sc.context)
.origins("Fisherman's Wharf, San Francisco")
.destinations("San Francisco International Airport, San Francisco, CA")
.mode(TravelMode.DRIVING)
.trafficModel(TrafficModel.PESSIMISTIC)
.departureTime(new DateTime(System.currentTimeMillis() + ONE_HOUR_MILLIS))
.await();
sc.assertParamValue("Fisherman's Wharf, San Francisco", "origins");
sc.assertParamValue("San Francisco International Airport, San Francisco, CA", "destinations");
sc.assertParamValue(TravelMode.DRIVING.toUrlValue(), "mode");
sc.assertParamValue(TrafficModel.PESSIMISTIC.toUrlValue(), "traffic_model");
}
}
开发者ID:googlemaps,项目名称:google-maps-services-java,代码行数:20,代码来源:DistanceMatrixApiTest.java
示例9: testResponseTimesArePopulatedCorrectly
import com.google.maps.model.TravelMode; //导入依赖的package包/类
@Test
public void testResponseTimesArePopulatedCorrectly() throws Exception {
try (LocalTestServerContext sc =
new LocalTestServerContext(responseTimesArePopulatedCorrectly)) {
DirectionsResult result =
DirectionsApi.newRequest(sc.context)
.mode(TravelMode.TRANSIT)
.origin("483 George St, Sydney NSW 2000, Australia")
.destination("182 Church St, Parramatta NSW 2150, Australia")
.await();
assertEquals(1, result.routes.length);
assertEquals(1, result.routes[0].legs.length);
DateTimeFormatter fmt = DateTimeFormat.forPattern("h:mm a");
assertEquals("1:54 pm", fmt.print(result.routes[0].legs[0].arrivalTime).toLowerCase());
assertEquals("1:21 pm", fmt.print(result.routes[0].legs[0].departureTime).toLowerCase());
sc.assertParamValue(TravelMode.TRANSIT.toUrlValue(), "mode");
sc.assertParamValue("483 George St, Sydney NSW 2000, Australia", "origin");
sc.assertParamValue("182 Church St, Parramatta NSW 2150, Australia", "destination");
}
}
开发者ID:googlemaps,项目名称:google-maps-services-java,代码行数:23,代码来源:DirectionsApiTest.java
示例10: testTorontoToMontrealByBicycleAvoidingHighways
import com.google.maps.model.TravelMode; //导入依赖的package包/类
/**
* Going from Toronto to Montreal by bicycle, avoiding highways.
*
* <p>{@code
* http://maps.googleapis.com/maps/api/directions/json?origin=Toronto&destination=Montreal&avoid=highways&mode=bicycling}
*/
@Test
public void testTorontoToMontrealByBicycleAvoidingHighways() throws Exception {
try (LocalTestServerContext sc =
new LocalTestServerContext("{\"routes\": [{}],\"status\": \"OK\"}")) {
DirectionsApi.newRequest(sc.context)
.origin("Toronto")
.destination("Montreal")
.avoid(DirectionsApi.RouteRestriction.HIGHWAYS)
.mode(TravelMode.BICYCLING)
.await();
sc.assertParamValue("Toronto", "origin");
sc.assertParamValue("Montreal", "destination");
sc.assertParamValue(RouteRestriction.HIGHWAYS.toUrlValue(), "avoid");
sc.assertParamValue(TravelMode.BICYCLING.toUrlValue(), "mode");
}
}
开发者ID:googlemaps,项目名称:google-maps-services-java,代码行数:24,代码来源:DirectionsApiTest.java
示例11: testBrooklynToQueensByTransit
import com.google.maps.model.TravelMode; //导入依赖的package包/类
/**
* Brooklyn to Queens by public transport.
*
* <p>{@code
* http://maps.googleapis.com/maps/api/directions/json?origin=Brooklyn&destination=Queens&departure_time=1343641500&mode=transit}
*/
@Test
public void testBrooklynToQueensByTransit() throws Exception {
try (LocalTestServerContext sc =
new LocalTestServerContext("{\"routes\": [{}],\"status\": \"OK\"}")) {
DirectionsApi.newRequest(sc.context)
.origin("Brooklyn")
.destination("Queens")
.mode(TravelMode.TRANSIT)
.await();
sc.assertParamValue("Brooklyn", "origin");
sc.assertParamValue("Queens", "destination");
sc.assertParamValue(TravelMode.TRANSIT.toUrlValue(), "mode");
}
}
开发者ID:googlemaps,项目名称:google-maps-services-java,代码行数:22,代码来源:DirectionsApiTest.java
示例12: testTrafficModel
import com.google.maps.model.TravelMode; //导入依赖的package包/类
/** Tests the {@code traffic_model} and {@code duration_in_traffic} parameters. */
@Test
public void testTrafficModel() throws Exception {
try (LocalTestServerContext sc =
new LocalTestServerContext("{\"routes\": [{}],\"status\": \"OK\"}"); ) {
DirectionsApi.newRequest(sc.context)
.origin("48 Pirrama Road, Pyrmont NSW 2009")
.destination("182 Church St, Parramatta NSW 2150")
.mode(TravelMode.DRIVING)
.departureTime(new DateTime().plus(Duration.standardMinutes(2)))
.trafficModel(TrafficModel.PESSIMISTIC)
.await();
sc.assertParamValue("48 Pirrama Road, Pyrmont NSW 2009", "origin");
sc.assertParamValue("182 Church St, Parramatta NSW 2150", "destination");
sc.assertParamValue(TravelMode.DRIVING.toUrlValue(), "mode");
sc.assertParamValue(TrafficModel.PESSIMISTIC.toUrlValue(), "traffic_model");
}
}
开发者ID:googlemaps,项目名称:google-maps-services-java,代码行数:20,代码来源:DirectionsApiTest.java
示例13: testTransitWithoutSpecifyingTime
import com.google.maps.model.TravelMode; //导入依赖的package包/类
/** Test transit without arrival or departure times specified. */
@Test
public void testTransitWithoutSpecifyingTime() throws Exception {
try (LocalTestServerContext sc =
new LocalTestServerContext("{\"routes\": [{}],\"status\": \"OK\"}")) {
DirectionsApi.newRequest(sc.context)
.origin("Fisherman's Wharf, San Francisco")
.destination("Union Square, San Francisco")
.mode(TravelMode.TRANSIT)
.await();
sc.assertParamValue("Fisherman's Wharf, San Francisco", "origin");
sc.assertParamValue("Union Square, San Francisco", "destination");
sc.assertParamValue(TravelMode.TRANSIT.toUrlValue(), "mode");
}
}
开发者ID:googlemaps,项目名称:google-maps-services-java,代码行数:17,代码来源:DirectionsApiTest.java
示例14: testTransitParams
import com.google.maps.model.TravelMode; //导入依赖的package包/类
/** Test the extended transit parameters: mode and routing preference. */
@Test
public void testTransitParams() throws Exception {
try (LocalTestServerContext sc =
new LocalTestServerContext("{\"routes\": [{}],\"status\": \"OK\"}")) {
DirectionsApi.newRequest(sc.context)
.origin("Fisherman's Wharf, San Francisco")
.destination("Union Square, San Francisco")
.mode(TravelMode.TRANSIT)
.transitMode(TransitMode.BUS, TransitMode.TRAM)
.transitRoutingPreference(TransitRoutingPreference.LESS_WALKING)
.await();
sc.assertParamValue("Fisherman's Wharf, San Francisco", "origin");
sc.assertParamValue("Union Square, San Francisco", "destination");
sc.assertParamValue(TravelMode.TRANSIT.toUrlValue(), "mode");
sc.assertParamValue(
TransitMode.BUS.toUrlValue() + "|" + TransitMode.TRAM.toUrlValue(), "transit_mode");
sc.assertParamValue(
TransitRoutingPreference.LESS_WALKING.toUrlValue(), "transit_routing_preference");
}
}
开发者ID:googlemaps,项目名称:google-maps-services-java,代码行数:23,代码来源:DirectionsApiTest.java
示例15: testTravelModeWalking
import com.google.maps.model.TravelMode; //导入依赖的package包/类
@Test
public void testTravelModeWalking() throws Exception {
try (LocalTestServerContext sc =
new LocalTestServerContext("{\"routes\": [{}],\"status\": \"OK\"}"); ) {
DirectionsResult result =
DirectionsApi.newRequest(sc.context)
.mode(TravelMode.WALKING)
.origin("483 George St, Sydney NSW 2000, Australia")
.destination("182 Church St, Parramatta NSW 2150, Australia")
.await();
assertNotNull(result.routes);
assertNotNull(result.routes[0]);
sc.assertParamValue(TravelMode.WALKING.toUrlValue(), "mode");
sc.assertParamValue("483 George St, Sydney NSW 2000, Australia", "origin");
sc.assertParamValue("182 Church St, Parramatta NSW 2150, Australia", "destination");
}
}
开发者ID:googlemaps,项目名称:google-maps-services-java,代码行数:20,代码来源:DirectionsApiTest.java
示例16: validateRequest
import com.google.maps.model.TravelMode; //导入依赖的package包/类
@Override
protected void validateRequest() {
if (!params().containsKey("origins")) {
throw new IllegalArgumentException("Request must contain 'origins'");
}
if (!params().containsKey("destinations")) {
throw new IllegalArgumentException("Request must contain 'destinations'");
}
if (TravelMode.TRANSIT.toString().equals(params().get("mode"))
&& (params().containsKey("arrival_time") && params().containsKey("departure_time"))) {
throw new IllegalArgumentException(
"Transit request must not contain both a departureTime and an arrivalTime");
}
}
开发者ID:googlemaps,项目名称:google-maps-services-java,代码行数:15,代码来源:DistanceMatrixApiRequest.java
示例17: testNewRequestWithAllPossibleParams
import com.google.maps.model.TravelMode; //导入依赖的package包/类
@Test
public void testNewRequestWithAllPossibleParams() throws Exception {
try (LocalTestServerContext sc = new LocalTestServerContext("{\"status\" : \"OK\"}")) {
String[] origins =
new String[] {
"Perth, Australia", "Sydney, Australia", "Melbourne, Australia",
"Adelaide, Australia", "Brisbane, Australia", "Darwin, Australia",
"Hobart, Australia", "Canberra, Australia"
};
String[] destinations =
new String[] {
"Uluru, Australia",
"Kakadu, Australia",
"Blue Mountains, Australia",
"Bungle Bungles, Australia",
"The Pinnacles, Australia"
};
DistanceMatrixApi.newRequest(sc.context)
.origins(origins)
.destinations(destinations)
.mode(TravelMode.DRIVING)
.language("en-AU")
.avoid(RouteRestriction.TOLLS)
.units(Unit.IMPERIAL)
.departureTime(new DateTime().plusMinutes(2)) // this is ignored when an API key is used
.await();
sc.assertParamValue(StringUtils.join(origins, "|"), "origins");
sc.assertParamValue(StringUtils.join(destinations, "|"), "destinations");
sc.assertParamValue(TravelMode.DRIVING.toUrlValue(), "mode");
sc.assertParamValue("en-AU", "language");
sc.assertParamValue(RouteRestriction.TOLLS.toUrlValue(), "avoid");
sc.assertParamValue(Unit.IMPERIAL.toUrlValue(), "units");
}
}
开发者ID:googlemaps,项目名称:google-maps-services-java,代码行数:37,代码来源:DistanceMatrixApiTest.java
示例18: testBuilder
import com.google.maps.model.TravelMode; //导入依赖的package包/类
@Test
public void testBuilder() throws Exception {
try (LocalTestServerContext sc = new LocalTestServerContext(builderResponse)) {
DirectionsResult result =
DirectionsApi.newRequest(sc.context)
.mode(TravelMode.BICYCLING)
.avoid(
DirectionsApi.RouteRestriction.HIGHWAYS,
DirectionsApi.RouteRestriction.TOLLS,
DirectionsApi.RouteRestriction.FERRIES)
.units(Unit.METRIC)
.region("au")
.origin("Sydney")
.destination("Melbourne")
.await();
assertNotNull(result.routes);
assertEquals(1, result.routes.length);
sc.assertParamValue(TravelMode.BICYCLING.toUrlValue(), "mode");
sc.assertParamValue(
DirectionsApi.RouteRestriction.HIGHWAYS.toUrlValue()
+ "|"
+ DirectionsApi.RouteRestriction.TOLLS.toUrlValue()
+ "|"
+ DirectionsApi.RouteRestriction.FERRIES.toUrlValue(),
"avoid");
sc.assertParamValue(Unit.METRIC.toUrlValue(), "units");
sc.assertParamValue("au", "region");
sc.assertParamValue("Sydney", "origin");
sc.assertParamValue("Melbourne", "destination");
}
}
开发者ID:googlemaps,项目名称:google-maps-services-java,代码行数:34,代码来源:DirectionsApiTest.java
示例19: testGeocodedWaypoints
import com.google.maps.model.TravelMode; //导入依赖的package包/类
/** Test GeocodedWaypoints results. */
@Test
public void testGeocodedWaypoints() throws Exception {
try (LocalTestServerContext sc =
new LocalTestServerContext(
"{"
+ " \"geocoded_waypoints\" : [\n"
+ " {\n"
+ " \"geocoder_status\" : \"OK\"\n"
+ " },\n"
+ " {\n"
+ " \"geocoder_status\" : \"OK\",\n"
+ " \"types\" : [\"route\"]\n"
+ " }\n"
+ " ],\n"
+ " \"routes\": [{}],\n"
+ " \"status\": \"OK\"\n"
+ "}")) {
DirectionsResult result =
DirectionsApi.newRequest(sc.context)
.origin("48 Pirrama Rd, Pyrmont NSW")
.destination("Airport Dr, Sydney NSW")
.mode(TravelMode.DRIVING)
.await();
assertNotNull(result.geocodedWaypoints);
assertEquals(2, result.geocodedWaypoints.length);
assertEquals(GeocodedWaypointStatus.OK, result.geocodedWaypoints[0].geocoderStatus);
assertEquals(GeocodedWaypointStatus.OK, result.geocodedWaypoints[1].geocoderStatus);
assertEquals(AddressType.ROUTE, result.geocodedWaypoints[1].types[0]);
}
}
开发者ID:googlemaps,项目名称:google-maps-services-java,代码行数:33,代码来源:DirectionsApiTest.java
示例20: recalculateRoute
import com.google.maps.model.TravelMode; //导入依赖的package包/类
private void recalculateRoute(TravelMode travelMode) {
saveCurrentTravelMode(travelMode);
recalculateRouteTask = new RecalculateRouteTask()
.origin(getCurrentLocationArg())
.pois(pois)
.travelMode(travelMode);
recalculateRouteTask.request();
}
开发者ID:dan-zx,项目名称:rox-android,代码行数:9,代码来源:RecommendedRouteFragment.java
注:本文中的com.google.maps.model.TravelMode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论