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


Java PolylineOptions类代码示例

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


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

示例1: onMapReady

import com.google.android.gms.maps.model.PolylineOptions; //导入依赖的package包/类
/**
 * Manipulates the map once available.
 * This callback is triggered when the map is ready to be used.
 * This is where we can add markers or lines, add listeners or move the camera. In this case,
 * we just add a marker near Sydney, Australia.
 * If Google Play services is not installed on the device, the user will be prompted to install
 * it inside the SupportMapFragment. This method will only be triggered once the user has
 * installed Google Play services and returned to the app.
 */
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    if(checkingStation)
    {
        updateMap(mMap,stationPos);
        mMap.moveCamera(CameraUpdateFactory.newLatLng(stationPos));
        mMap.moveCamera(CameraUpdateFactory.zoomTo(15));
    }
    else
    {
        try {
            PolylineOptions mPolyOpt = getFromJSONArray(track);
            updateMap(mMap,mPolyOpt);
            mMap.moveCamera(CameraUpdateFactory.newLatLng(mPolyOpt.getPoints().get(0)));
            mMap.moveCamera(CameraUpdateFactory.zoomTo(15));

        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

}
 
开发者ID:carlosfaria94,项目名称:UbiBike-client,代码行数:34,代码来源:DisplayRoute.java

示例2: addPolyline

import com.google.android.gms.maps.model.PolylineOptions; //导入依赖的package包/类
/**
 * If an origin and destination exist this will draw a line between them and
 * render the time it takes to reach the {@link DistanceAction#destination}
 */
private void addPolyline() {
    if (this.origin == null || this.destination == null) {
        return;
    }
    releasePolyline();
    this.destination.marker.setTitle(getTitleForDistance(getDistance()));
    this.destination.marker.setSnippet(this.snippet);
    this.destination.marker.showInfoWindow();
    final PolylineOptions polylineOptions = new PolylineOptions();
    polylineOptions.add(this.origin.latLng);
    polylineOptions.add(this.destination.latLng);
    polylineOptions.width(5);
    polylineOptions.color(this.colorAccent);
    polylineOptions.zIndex(1000);
    this.polyline = this.mapController.addPolyline(polylineOptions);
}
 
开发者ID:ZafraniTechLLC,项目名称:Companion-For-PUBG-Android,代码行数:21,代码来源:DistanceAction.java

示例3: onDirectionFinderSuccess

import com.google.android.gms.maps.model.PolylineOptions; //导入依赖的package包/类
@Override
public void onDirectionFinderSuccess(List<Route> routes, Route routeObject) {
    callProgressDialog();
    polylinePaths = new ArrayList<>();

    if (!routes.isEmpty()) {
        for (Route route : routes) {
            PolylineOptions polylineOptions = new PolylineOptions().
                    color(Color.BLUE).
                    width(5);

            for (int i = 0; i < route.getPoints().size(); i++)
                polylineOptions.add(route.getPoints().get(i));

            polylinePaths.add(googleMap.addPolyline(polylineOptions));

        }

        //It allows to know to the Fragment that there is a new Route
        placesListener.onLocationsChange(routeObject);
    } else
        Toast.makeText(this, "There is no results", Toast.LENGTH_SHORT).show();
}
 
开发者ID:Balthair94,项目名称:AppGoogleMaps,代码行数:24,代码来源:MainActivity.java

示例4: trk2TrkOpts

import com.google.android.gms.maps.model.PolylineOptions; //导入依赖的package包/类
static PolylineOptions trk2TrkOpts(Track trk) {
    List<TrackPoint> trkPts = new ArrayList<>();

    for (TrackSegment seg : trk.getTrackSegments()) {
        trkPts.addAll(seg.getTrackPoints());
    }

    PolylineOptions pos = PolylilneStyle.getDefaultStyle();

    for (TrackPoint trkPt : trkPts) {
        LatLng latLng = new LatLng(trkPt.getLatitude(), trkPt.getLongitude());
        pos.add(latLng);
    }

    return pos;
}
 
开发者ID:typebrook,项目名称:FiveMinsMore,代码行数:17,代码来源:GpxUtils.java

示例5: onParserTaskfinish

import com.google.android.gms.maps.model.PolylineOptions; //导入依赖的package包/类
@Override
public void onParserTaskfinish(LatLng startCoordinate, LatLng endCoordinate, PolylineOptions lineOptions, List<Location> locations) {
    planningDialog.dismiss();
    Intent navigationActivity = new Intent(getBaseContext(), NavigationActivity.class);
    navigationActivity.putExtra(NavigationActivity.START_COORDINATE_EXTRA, startCoordinate);
    navigationActivity.putExtra(NavigationActivity.END_COORDINATE_EXTRA, endCoordinate);
    navigationActivity.putExtra(NavigationActivity.POLY_LINE_OPTIONS_EXTRA, lineOptions);

    if(locations == null){
        Log.d("Intent","failed");
    }
    else{
        Log.d("Intent","success");
        Gson gson = new Gson();
        Type type = new TypeToken<List<Location>>() {}.getType();
        String json = gson.toJson(locations, type);
        Log.d("Intent",json);
        Log.d("Location Count",Integer.toString(locations.size()));
        navigationActivity.putExtra(NavigationActivity.ADDITIONAL_LOCATION_EXTRA, json);
    }

    startActivity(navigationActivity);
    overridePendingTransition(R.anim.slide_from_right, R.anim.slide_to_left);
}
 
开发者ID:w86763777,项目名称:BikeLine,代码行数:25,代码来源:MainActivity.java

示例6: MapHandler

import com.google.android.gms.maps.model.PolylineOptions; //导入依赖的package包/类
/**
 * Constructor of the class
 *
 * @param googleMap a google map
 * @param trackColor the color of the track
 */
public MapHandler(GoogleMap googleMap, int trackColor) {
    if (googleMap == null) {
        throw new IllegalArgumentException();
    }

    this.trackColor = trackColor;

    this.googleMap = googleMap;
    this.googleMap.setLocationSource(null);

    uiSettings = this.googleMap.getUiSettings();
    uiSettings.setMyLocationButtonEnabled(false);
    uiSettings.setCompassEnabled(false);

    polylineOptions = new PolylineOptions();
}
 
开发者ID:IrrilevantHappyLlamas,项目名称:Runnest,代码行数:23,代码来源:MapHandler.java

示例7: toPolyline

import com.google.android.gms.maps.model.PolylineOptions; //导入依赖的package包/类
/**
 * Convert a {@link LineString} to a {@link PolylineOptions}
 *
 * @param lineString
 * @return
 */
public PolylineOptions toPolyline(LineString lineString) {

    PolylineOptions polylineOptions = new PolylineOptions();
    Double z = null;

    // Try to simplify the number of points in the line string
    List<Point> points = simplifyPoints(lineString.getPoints());

    for (Point point : points) {
        LatLng latLng = toLatLng(point);
        polylineOptions.add(latLng);
        if (point.hasZ()) {
            z = (z == null) ? point.getZ() : Math.max(z, point.getZ());
        }
    }

    if (lineString.hasZ() && z != null) {
        polylineOptions.zIndex(z.floatValue());
    }

    return polylineOptions;
}
 
开发者ID:ngageoint,项目名称:geopackage-android-map,代码行数:29,代码来源:GoogleMapShapeConverter.java

示例8: addPolylineToMapAsMarkers

import com.google.android.gms.maps.model.PolylineOptions; //导入依赖的package包/类
/**
 * Add a Polyline to the map as markers
 *
 * @param map
 * @param polylineOptions
 * @param polylineMarkerOptions
 * @param globalPolylineOptions
 * @return
 */
public PolylineMarkers addPolylineToMapAsMarkers(GoogleMap map,
                                                 PolylineOptions polylineOptions,
                                                 MarkerOptions polylineMarkerOptions,
                                                 PolylineOptions globalPolylineOptions) {

    PolylineMarkers polylineMarkers = new PolylineMarkers(this);

    if (globalPolylineOptions != null) {
        polylineOptions.color(globalPolylineOptions.getColor());
        polylineOptions.geodesic(globalPolylineOptions.isGeodesic());
    }

    Polyline polyline = addPolylineToMap(map, polylineOptions);
    polylineMarkers.setPolyline(polyline);

    List<Marker> markers = addPointsToMapAsMarkers(map,
            polylineOptions.getPoints(), polylineMarkerOptions, false);
    polylineMarkers.setMarkers(markers);

    return polylineMarkers;
}
 
开发者ID:ngageoint,项目名称:geopackage-android-map,代码行数:31,代码来源:GoogleMapShapeConverter.java

示例9: addMultiPolylineToMapAsMarkers

import com.google.android.gms.maps.model.PolylineOptions; //导入依赖的package包/类
/**
 * Add a MultiPolylineOptions to the map as markers
 *
 * @param shapeMarkers
 * @param map
 * @param multiPolyline
 * @param polylineMarkerOptions
 * @param globalPolylineOptions
 * @return
 */
public MultiPolylineMarkers addMultiPolylineToMapAsMarkers(
        GoogleMapShapeMarkers shapeMarkers, GoogleMap map,
        MultiPolylineOptions multiPolyline,
        MarkerOptions polylineMarkerOptions,
        PolylineOptions globalPolylineOptions) {
    MultiPolylineMarkers polylines = new MultiPolylineMarkers();
    for (PolylineOptions polylineOptions : multiPolyline
            .getPolylineOptions()) {
        PolylineMarkers polylineMarker = addPolylineToMapAsMarkers(map,
                polylineOptions, polylineMarkerOptions,
                globalPolylineOptions);
        shapeMarkers.add(polylineMarker);
        polylines.add(polylineMarker);
    }
    return polylines;
}
 
开发者ID:ngageoint,项目名称:geopackage-android-map,代码行数:27,代码来源:GoogleMapShapeConverter.java

示例10: addInterval

import com.google.android.gms.maps.model.PolylineOptions; //导入依赖的package包/类
private void addInterval(Context context, GoogleMap map, ProcessedDataModel item, boolean addCache) {
    double[] coordsStart = item.getCoordsStart();
    double[] coordsEnd = item.getCoordsStart();
    if (coordsStart == null || coordsEnd == null
            || coordsStart.length < 2 || coordsEnd.length < 2) {
        return;
    }
    LatLng startLine = new LatLng(item.getCoordsStart()[0], item.getCoordsStart()[1]);
    LatLng endLine = new LatLng(item.getCoordsEnd()[0], item.getCoordsEnd()[1]);
    Polyline line = map.addPolyline(new PolylineOptions()
            .add(startLine, endLine)
            .geodesic(true)
            .width(context.getResources().getDimension(R.dimen.map_polyline_width))
            .color(getIriColor(context, item.getCategory())));
    if (addCache && linesCache != null) {
        linesCache.put(line, item);
    }
}
 
开发者ID:WorldBank-Transport,项目名称:RoadLab-Pro,代码行数:19,代码来源:MeasurementsGoogleMapHelper.java

示例11: drawGraph

import com.google.android.gms.maps.model.PolylineOptions; //导入依赖的package包/类
/**
 * @param graph to use in drawing polyOptions on the graph.
 */

@Override
public void drawGraph(Graph graph) {
    PolylineOptions graphOptions = new PolylineOptions();
    List<Location> locationList = graph.getLocations();

    for (Location location: locationList){
        LatLng currentPosition = new LatLng(location.getLatitude(), location.getLongitude());
        MarkerOptions options = new MarkerOptions();
        options.position(currentPosition)
                .icon(BitmapDescriptorFactory.defaultMarker())
                .title("Position")
                .snippet("Some Position");
        googleMap.addMarker(options);
        graphOptions.add(currentPosition);
    }

    Polyline graphPolygon = googleMap.addPolyline(graphOptions);

    graphPolygon.setGeodesic(true);
    graphPolygon.setColor(Color.DKGRAY);
    graphPolygon.setWidth(20);
}
 
开发者ID:aumarbello,项目名称:WalkGraph,代码行数:27,代码来源:MapFragmentImpl.java

示例12: drawSubsection

import com.google.android.gms.maps.model.PolylineOptions; //导入依赖的package包/类
public static void drawSubsection(GoogleMap map, List<LatLng> coords, int startIndex, int endIndex, int color){
  if(sectionPolyline != null){
    sectionPolyline.remove();
  }

  PolylineOptions line = new PolylineOptions();
  line.geodesic(true);
  line.width(14);
  line.zIndex(100);
  line.color(color);

  int start = startIndex;
  int end = endIndex;

  if(startIndex > endIndex){
    int temp = startIndex;
    start = endIndex;
    end = temp;
  }

  for(LatLng ll : coords.subList(start, end)){
    line.add(ll);
  }

  sectionPolyline = map.addPolyline(line);
}
 
开发者ID:fiskurgit,项目名称:KortidTol,代码行数:27,代码来源:MapTools.java

示例13: onMapReady

import com.google.android.gms.maps.model.PolylineOptions; //导入依赖的package包/类
@Override
public void onMapReady(GoogleMap googleMap) {

    mMap = googleMap;
    int marca = 0;

    for (Punto incidencia :incidencias) {
        mMap.addMarker(new MarkerOptions().position(new LatLng(incidencia.getX(), incidencia.getY())).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_VIOLET)));
    }

    for (Punto punto : puntos) {
        mMap.addMarker(new MarkerOptions().position(new LatLng(punto.getX(), punto.getY())).title("Step " + (++marca)));
    }
    mMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(puntos.get(0).getX(), puntos.get(0).getY())));

    UiSettings ui = mMap.getUiSettings();
    ui.setZoomControlsEnabled(true);


    for (int i = 0; i < puntos.size() - 1; i++) {
        PolylineOptions linea = new PolylineOptions().add(new LatLng(puntos.get(i).getX(), puntos.get(i).getY())).add(new LatLng(puntos.get(i + 1).getX(), puntos.get(i + 1).getY()));
        linea.color(Color.BLUE);
        linea.width(3f);
        mMap.addPolyline(linea);
    }
}
 
开发者ID:santiihoyos,项目名称:LazarilloApp,代码行数:27,代码来源:MapsActivity.java

示例14: drawRoute

import com.google.android.gms.maps.model.PolylineOptions; //导入依赖的package包/类
/**
 * Helper function used to draw routes on the map given 2 locations
 *
 * @param mMap
 * @param decodedPolyLine
 * @param polylineArrayList
 * @return
 */
public int drawRoute(GoogleMap mMap, List<LatLng> decodedPolyLine, ArrayList<Polyline> polylineArrayList) {
    int routeDistance = 0;
    for (int i = 0; i < (decodedPolyLine.size() - 1); i++) {
        LatLng point1 = decodedPolyLine.get(i);
        LatLng point2 = decodedPolyLine.get(i + 1);

        Location location1 = new Location("1");
        location1.setLatitude(point1.latitude);
        location1.setLongitude(point1.longitude);
        Location location2 = new Location("2");
        location2.setLatitude(point2.latitude);
        location2.setLongitude(point2.longitude);

        routeDistance += location1.distanceTo(location2);
        polylineArrayList.add(mMap.addPolyline(new PolylineOptions()
                .add(point1, point2)
                .width(5)
                .color(Color.RED)));
    }
    return routeDistance;
}
 
开发者ID:CMPUT301F16T02,项目名称:Dryver,代码行数:30,代码来源:MapUtil.java

示例15: onActivityResult

import com.google.android.gms.maps.model.PolylineOptions; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == NAVIGATION_REQUEST_CODE) {
        stopService(LocService);
        EventoLocalizacion actual;
        ArrayList<LatLng> localizaciones = new ArrayList<>();
        for (int i = 0; i < listaLocalizaciones.size(); i++) {
            actual = listaLocalizaciones.get(i);
            mapa.addMarker(new MarkerOptions().title("Punto " + Integer.toString(i) + " " + actual.tiempo).position(actual.localizacion));
            localizaciones.add(actual.localizacion);
        }

        mapa.addPolyline(new PolylineOptions().addAll(localizaciones).color(Color.RED));

        mapa.moveCamera(CameraUpdateFactory.newLatLngZoom(localizaciones.get(localizaciones.size() - 1), 15));

    }

}
 
开发者ID:ranea,项目名称:AppsAndroid,代码行数:20,代码来源:NavegacionActivity.java


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