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


Java DirectionsRoute类代码示例

本文整理汇总了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;未经允许,请勿转载。