當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。