当前位置: 首页>>代码示例>>Java>>正文


Java Unit类代码示例

本文整理汇总了Java中com.google.maps.model.Unit的典型用法代码示例。如果您正苦于以下问题:Java Unit类的具体用法?Java Unit怎么用?Java Unit使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Unit类属于com.google.maps.model包,在下文中一共展示了Unit类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDistanceMatrix

import com.google.maps.model.Unit; //导入依赖的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

示例2: testNewRequestWithAllPossibleParams

import com.google.maps.model.Unit; //导入依赖的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

示例3: testBuilder

import com.google.maps.model.Unit; //导入依赖的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

示例4: units

import com.google.maps.model.Unit; //导入依赖的package包/类
/**
 * Specifies the unit system to use when expressing distance as text. Distance Matrix results
 * contain text within distance fields to indicate the distance of the calculated route.
 *
 * @param unit One of {@link Unit#METRIC} or {@link Unit#IMPERIAL}.
 * @see <a
 *     href="https://developers.google.com/maps/documentation/distance-matrix/intro#unit_systems">
 *     Unit systems in the Distance Matrix API</a>
 * @return Returns this {@code DistanceMatrixApiRequest} for call chaining.
 */
public DistanceMatrixApiRequest units(Unit unit) {
  return param("units", unit);
}
 
开发者ID:googlemaps,项目名称:google-maps-services-java,代码行数:14,代码来源:DistanceMatrixApiRequest.java


注:本文中的com.google.maps.model.Unit类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。