• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DirectionsRoute类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: call

import com.google.maps.model.DirectionsRoute; //导入依赖的package包/类
@Override
public Pair<Poi[], DirectionsRoute> call() throws Exception {
    Poi[] nextPois = poisApi.awaitRoute(seed.getFoursquareId());
    List<Poi> pois = new ArrayList<>();
    pois.add(seed);
    pois.addAll(Arrays.asList(nextPois));
    String[] waypoints = new String[pois.size()-1];
    for (int i = 0; i < waypoints.length; i++) waypoints[i] = toGoogleMapsServicesLatLng(pois.get(i).getLocation());
    DirectionsRoute[] routes = DirectionsApi.newRequest(geoApiContext)
            .origin(toGoogleMapsServicesLatLng(origin))
            .destination(toGoogleMapsServicesLatLng(pois.get(pois.size()-1).getLocation()))
            .mode(travelMode)
            .waypoints(waypoints)
            .await();
    return new Pair(nextPois, routes == null || routes.length == 0 ? null : routes[0]);
}
 
开发者ID:dan-zx,项目名称:rox-android,代码行数:17,代码来源:RecommendedRouteFragment.java


示例2: onAcquireRoute

import com.google.maps.model.DirectionsRoute; //导入依赖的package包/类
private void onAcquireRoute(DirectionsRoute route) {
    this.route = route;
    if (route != null) {
        double totalDistance = 0f;
        for (DirectionsLeg leg : route.legs) totalDistance += leg.distance.inMeters;
        travelDistanceTextView.setText(getString(R.string.travel_distance, totalDistance / 1_000f));
        travelDistanceContainer.setVisibility(View.VISIBLE);
        List<com.google.maps.model.LatLng> polyline = route.overviewPolyline.decodePath();
        PolylineOptions pathOptions = new PolylineOptions().color(getResources().getColor(R.color.accent));
        for (com.google.maps.model.LatLng point : polyline) pathOptions.add(new LatLng(point.lat, point.lng));
        googleMap.addPolyline(pathOptions);
    } else {
        Toast.makeText(getActivity().getApplicationContext(),
                R.string.unavailable_route, Toast.LENGTH_SHORT).show();
    }
}
 
开发者ID:dan-zx,项目名称:rox-android,代码行数:17,代码来源:RecommendedRouteFragment.java


示例3: getCoordinatesFromGoogle

import com.google.maps.model.DirectionsRoute; //导入依赖的package包/类
@Override
public List<Point> getCoordinatesFromGoogle(DirectionInput directionInput) {

	final GeoApiContext context = new GeoApiContext().setApiKey(environment.getRequiredProperty("gpsSimmulator.googleApiKey"));
	final DirectionsApiRequest request =  DirectionsApi.getDirections(
		context,
		directionInput.getFrom(),
		directionInput.getTo());
	List<LatLng> latlongList = null;

	try {
		DirectionsRoute[] routes = request.await();

		for (DirectionsRoute route : routes) {
			latlongList = route.overviewPolyline.decodePath();
		}
	}
	catch (Exception e) {
		throw new IllegalStateException(e);
	}

	final List<Point> points = new ArrayList<>(latlongList.size());

	for (LatLng latLng : latlongList) {
		points.add(new Point(latLng.lat, latLng.lng));
	}

	return points;
}
 
开发者ID:ghillert,项目名称:gps-vehicle-simulator,代码行数:30,代码来源:DefaultPathService.java


示例4: BikeableRoute

import com.google.maps.model.DirectionsRoute; //导入依赖的package包/类
public BikeableRoute(DirectionsRoute directionsRoute, GoogleMap mMap, long distance) {
    this.directionsRoute = directionsRoute;

    this.distance = distance;
    duration = calculateEstimatedBikingDuration();
    durationString = updateDurationString();
    distanceString = updateDistanceString();

    elevationQuerier = new PathElevationQuerier(this.directionsRoute.overviewPolyline);
    numOfElevationSamples = calcNumOfSamples();
    routeElevationArr = createGraphElevationArray();
    pathElevationScoreCalculator = new PathElevationScoreCalculator(routeElevationArr, distance);
    averageUphillDegree = pathElevationScoreCalculator.getAvregeUphillDegree();
    worstDegree = pathElevationScoreCalculator.calcWorstDegree();
    pathElevationScore = pathElevationScoreCalculator.getPathScore();

    routePolylineOptions = createRoutesPolyOpts();
    routePolyline = mMap.addPolyline(routePolylineOptions); // draws the polyline on map
    colorizeUphillSections = new ColorizeUphillSections(this);
    colorizeUphillSections.addUphillSectionsToMap(mMap);
    if (IriaData.isDataReceived) {
        BikePathCalculator pathCalculator = new BikePathCalculator(routePolylineOptions, IriaData.getBikePathsTLVPolyLineOpt(),
                directionsRoute);
        bikePathPercentage = pathCalculator.getBikePathPercentageByRoute();
        bikePathInRoute = pathCalculator.getBikePaths();
        addBikePathToMap(mMap);
    }

    algorithmScore = 0;
}
 
开发者ID:nogalavi,项目名称:Bikeable,代码行数:31,代码来源:BikeableRoute.java


示例5: BikePathCalculator

import com.google.maps.model.DirectionsRoute; //导入依赖的package包/类
public BikePathCalculator (PolylineOptions currentRoutePolylineOpt,
                           ArrayList <PolylineOptions> iriaPaths, DirectionsRoute currDirectionRoute){
    routePolylineOpt = currentRoutePolylineOpt;
    iriaPathsList = iriaPaths;
    directionsRoute = currDirectionRoute;
    totalInRoutePaths = new ArrayList<>();
}
 
开发者ID:nogalavi,项目名称:Bikeable,代码行数:8,代码来源:BikePathCalculator.java


示例6: addNewRoutes

import com.google.maps.model.DirectionsRoute; //导入依赖的package包/类
private void addNewRoutes(DirectionsRoute[] directionsRouteArr, GoogleMap mMap) {
    for (DirectionsRoute directionsRoute: directionsRouteArr){
        long distance = calcRouteDistance(directionsRoute);
        if (distance <= 20){
            continue;
        }
        BikeableRoute currBikeableRoute = new BikeableRoute(directionsRoute, mMap, distance);
        bikeableRoutes.add(currBikeableRoute);
    }
}
 
开发者ID:nogalavi,项目名称:Bikeable,代码行数:11,代码来源:AllRoutes.java


示例7: calcRouteDistance

import com.google.maps.model.DirectionsRoute; //导入依赖的package包/类
private long calcRouteDistance(DirectionsRoute directionsRoute) {
    long distance = 0;
    for (DirectionsLeg leg : directionsRoute.legs) {
        distance += leg.distance.inMeters;
    }
    return distance;
}
 
开发者ID:nogalavi,项目名称:Bikeable,代码行数:8,代码来源:AllRoutes.java


示例8: getCalculatedRoutes

import com.google.maps.model.DirectionsRoute; //导入依赖的package包/类
public DirectionsRoute[] getCalculatedRoutes(){
    return calculatedRoutes;
}
 
开发者ID:nogalavi,项目名称:Bikeable,代码行数:4,代码来源:DirectionsManager.java


示例9: updateBikeableRoutesAndMap

import com.google.maps.model.DirectionsRoute; //导入依赖的package包/类
public void updateBikeableRoutesAndMap(DirectionsRoute[] directionsRouteArr, GoogleMap mMap, UserPreferences userPreferences) {
    removeCurrentRoutes();
    addNewRoutes(directionsRouteArr, mMap);
    bestRouteIndex = calculateBestRouteIndex(userPreferences); // by now, all routes are already updated
    selectAndColorRoute(bestRouteIndex);
}
 
开发者ID:nogalavi,项目名称:Bikeable,代码行数:7,代码来源:AllRoutes.java


示例10: onSuccess

import com.google.maps.model.DirectionsRoute; //导入依赖的package包/类
@Override
protected void onSuccess(Pair<Poi[], DirectionsRoute> objects) throws Exception {
    super.onSuccess(objects);
    onAcquiredNextPois(objects._0);
    onAcquiredRoute(objects._1);
}
 
开发者ID:dan-zx,项目名称:rox-android,代码行数:7,代码来源:RecommendedRouteFragment.java


示例11: onAcquiredRoute

import com.google.maps.model.DirectionsRoute; //导入依赖的package包/类
private void onAcquiredRoute(DirectionsRoute route) {
    onAcquireRoute(route);
}
 
开发者ID:dan-zx,项目名称:rox-android,代码行数:4,代码来源:RecommendedRouteFragment.java


示例12: getBusRouteCallback

import com.google.maps.model.DirectionsRoute; //导入依赖的package包/类
private PendingResult.Callback<DirectionsResult> getBusRouteCallback(final List<BusStop> interStops, final BusStop startStop, final BusStop endStop
        , final LatLng startLatLng, final LatLng destLatLng) {
    return new PendingResult.Callback<DirectionsResult>() {
        @Override
        public void onResult(final DirectionsResult result) {
            activity.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    clearMap();
                    DirectionsRoute[] routes = result.routes;
                    EncodedPolyline polyline = routes[0].overviewPolyline;
                    PolylineOptions options = new PolylineOptions();
                    for (com.google.maps.model.LatLng latLng : polyline.decodePath()) {
                        options.add(new LatLng(latLng.lat, latLng.lng));
                    }
                    options.color(getResources().getColor(R.color.color_primary)).width(15);
                    googleMap.addPolyline(options);
                    addGoogleWarning(result);
                    LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
                    for (BusStop bs : interStops) {
                        drawBusStop(bs);
                        boundsBuilder.include(bs.getLatLng());
                    }
                    googleMap.addMarker(new MarkerOptions()
                            .position(startStop.getLatLng())
                            .title(startStop.getName()));
                    googleMap.addMarker(new MarkerOptions()
                            .position(endStop.getLatLng())
                            .title(endStop.getName()));
                    boundsBuilder.include(startStop.getLatLng());
                    boundsBuilder.include(endStop.getLatLng());
                    boundsBuilder.include(startLatLng);
                    boundsBuilder.include(destLatLng);
                    changeZoomLevel(googleMap, boundsBuilder.build());
                    addWalkingPath(startLatLng, startStop.getLatLng(), true, false);
                    addWalkingPath(destLatLng, endStop.getLatLng(), false, false);
                }
            });
        }

        @Override
        public void onFailure(Throwable e) {
            activity.showErrorToast(R.string.no_bus_route);
            addWalkingPath(startLatLng, destLatLng, true, true);
        }
    };
}
 
开发者ID:pennlabs,项目名称:penn-mobile-android,代码行数:48,代码来源:MapFragment.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OfflineRegionStatus类代码示例发布时间:2022-05-22
下一篇:
Java City类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap