本文整理匯總了Java中com.google.android.gms.maps.model.PolylineOptions.add方法的典型用法代碼示例。如果您正苦於以下問題:Java PolylineOptions.add方法的具體用法?Java PolylineOptions.add怎麽用?Java PolylineOptions.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.android.gms.maps.model.PolylineOptions
的用法示例。
在下文中一共展示了PolylineOptions.add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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;
}
示例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);
}
示例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();
}
示例4: 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;
}
示例5: 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);
}
示例6: 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);
}
示例7: drawPath
import com.google.android.gms.maps.model.PolylineOptions; //導入方法依賴的package包/類
private Polyline drawPath(List<LatLong> latLongs, int color, float zIndex, Polyline polyline) {
if (googleMap != null && latLongs != null && !latLongs.isEmpty()) {
PolylineOptions polyLineOptions = new PolylineOptions();
polyLineOptions.width(getResources().getDimension(R.dimen._2dp));
polyLineOptions.color(color);
polyLineOptions.zIndex(zIndex);
for (LatLong latLong : latLongs) {
polyLineOptions.add(new LatLng(latLong.latitude(), latLong.longitude()));
}
if (polyline != null) polyline.remove();
return googleMap.addPolyline(polyLineOptions);
}
return null;
}
示例8: setPolyline
import com.google.android.gms.maps.model.PolylineOptions; //導入方法依賴的package包/類
public void setPolyline(Polyline newPolyline){
if (oldPolyline != null){
oldPolyline.remove();
}
if (newPolyline == null){
return;
}
PolylineOptions options = new PolylineOptions()
.color(newPolyline.getColor())
.visible(newPolyline.isVisible())
.width(newPolyline.getWidth())
;
for (GeoPoint p : newPolyline.getPoints()){
options.add(new LatLng(p.getLatitude(), p.getLongitude()));
}
oldPolyline = map.addPolyline(options);
}
示例9: displayLinesAndAreas
import com.google.android.gms.maps.model.PolylineOptions; //導入方法依賴的package包/類
private void displayLinesAndAreas(List<ILatLonRecord> waypoints) {
try {
PolylineOptions polyline = new PolylineOptions().width(ResourcesHelper.getDimensionPixelSize(this, R.dimen.task_line_width)).color(getResources().getColor(R.color.task_line));
for (int i = 0; i < waypoints.size(); i++) {
CRecordWayPoint cRecordWayPoint = (CRecordWayPoint) waypoints.get(i);
if (cRecordWayPoint.getType() == CRecordType.START || cRecordWayPoint.getType() == CRecordType.TURN || cRecordWayPoint.getType() == CRecordType.FINISH) {
polyline.add(new LatLng(waypoints.get(i).getLatLon().getLat(), waypoints.get(i).getLatLon().getLon()));
}
if (cRecordWayPoint.getType() == CRecordType.TURN) {
googleMap.addCircle(new CircleOptions().center(new LatLng(waypoints.get(i).getLatLon().getLat(), waypoints.get(i).getLatLon().getLon()))
.radius(TaskConfig.getAreaWidth()).strokeColor(Color.TRANSPARENT)
.strokeWidth(getResources().getDimensionPixelSize(R.dimen.task_line_width))
.fillColor(getResources().getColor(R.color.task_fill_color)));
}
}
googleMap.addPolyline(polyline);
} catch (Throwable t) {
Logger.logError("Error trying to draw waypoints: " + t.getMessage());
}
}
示例10: getPath
import com.google.android.gms.maps.model.PolylineOptions; //導入方法依賴的package包/類
@Override
public PolylineOptions getPath(LatLng start, LatLng finish) {
// computes all possible paths from starting vertex
computePaths(latLngNodeMap.get(start));
// holds a list of vertices that make up the shortest path between start and finish
List <Vertex> path = getShortestPathTo(latLngNodeMap.get(finish));
PolylineOptions options = new PolylineOptions();
// add the LatLngs of each vertex in the path to the polyline
for (int i = 0; i < path.size(); i++) {
LatLng cords = new LatLng(path.get(i).lat, path.get(i).lon);
options.add(cords);
}
options.color(Color.BLUE);
return options;
}
示例11: onMapReady
import com.google.android.gms.maps.model.PolylineOptions; //導入方法依賴的package包/類
@Override
public void onMapReady(GoogleMap googleMap)
{
PolylineOptions polyOptions = new PolylineOptions();
List<String[]> result = SQLDBController.getInstance().query("SELECT attr_time, attr_lat, attr_lng FROM " + SQLTableName.PREFIX + DeviceID.get(this.context) + SQLTableName.GPS + " WHERE attr_time > ? AND attr_time < ?", new String[]{ String.valueOf(this.start), String.valueOf(this.end) }, false);
LatLng pos = null;
for(String[] row : result) {
pos = new LatLng(Float.valueOf(row[1]), Float.valueOf(row[2]));
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
polyOptions.add(pos);
positionMarkers.add(googleMap.addMarker(new MarkerOptions().title(sdf.format(new Date(Long.valueOf(row[0])))).position(pos)));
}
if(pos == null) {
return;
}
polyline = googleMap.addPolyline(polyOptions);
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(pos, 15));
}
示例12: drawPolyline
import com.google.android.gms.maps.model.PolylineOptions; //導入方法依賴的package包/類
protected void drawPolyline(List<Location> locationList) {
// add polyline to map + calculate bounding box
googleMap.clear();
PolylineOptions polylineOptions = new PolylineOptions();
LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
for (Location location : locationList) {
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
polylineOptions.add(latLng);
boundsBuilder.include(latLng);
}
googleMap.addPolyline(polylineOptions
.width(5)
.color(Color.BLUE));
int padding = (int) getResources().getDimension(R.dimen.map_bounds_padding);
googleMap.moveCamera(CameraUpdateFactory.newLatLngBounds(boundsBuilder.build(), padding));
}
示例13: getDirection
import com.google.android.gms.maps.model.PolylineOptions; //導入方法依賴的package包/類
private PolylineOptions getDirection() {
try {
GMapV2Direction md = new GMapV2Direction();
Document doc = md.getDocument(myLatLng, shopLatLng,
GMapV2Direction.MODE_WALKING);
ArrayList<LatLng> directionPoint = md.getDirection(doc);
PolylineOptions rectLine = new PolylineOptions().width(9).color(
Color.GREEN);
for (int i = 0; i < directionPoint.size(); i++) {
rectLine.add(directionPoint.get(i));
}
isDirectionDrawn = true;
return rectLine;
}
catch (Exception e)
{
///possible error:
///java.lang.IllegalStateException: Error using newLatLngBounds(LatLngBounds, int): Map size can't be 0. Most likely, layout has not yet occured for the map view. Either wait until layout has occurred or use newLatLngBounds(LatLngBounds, int, int, int) which allows you to specify the map's dimensions.
return null;
}
}
示例14: setUpPolylineOnMap
import com.google.android.gms.maps.model.PolylineOptions; //導入方法依賴的package包/類
/**
* Instantiates a new Polyline object on {@link GoogleMap} and adds points to define a rectangle.
*
* @param latLngs Array of {@link LatLng}
*/
public void setUpPolylineOnMap(ArrayList<Observation> mObservationsList) {
try {
// build LatLngs array from ObservationListFragment
LatLng[] mLatLngs = getLatLngArray(mObservationsList);
moveCameraToPosition(mLatLngs[0]);
PolylineOptions drawOptions = new PolylineOptions().width(7).color(Color.BLUE).geodesic(true);
for (int i = 0; i < mLatLngs.length; i++) {
drawOptions.add(mLatLngs[i]);
}
// Get back the mutable Polyline
mGoogleMap.addPolyline(drawOptions);
// finally show marker
showMarker(mObservationsList);
} catch (Exception e) {
}
}
示例15: onGpxButtonClick
import com.google.android.gms.maps.model.PolylineOptions; //導入方法依賴的package包/類
/**
* Handles the GPX button-click event, running the demo snippet {@link #loadGpxData}.
*/
public void onGpxButtonClick(View view) {
try {
mCapturedLocations = loadGpxData(Xml.newPullParser(),
getResources().openRawResource(R.raw.gpx_data));
findViewById(R.id.snap_to_roads).setEnabled(true);
LatLngBounds.Builder builder = new LatLngBounds.Builder();
PolylineOptions polyline = new PolylineOptions();
for (LatLng ll : mCapturedLocations) {
com.google.android.gms.maps.model.LatLng mapPoint =
new com.google.android.gms.maps.model.LatLng(ll.lat, ll.lng);
builder.include(mapPoint);
polyline.add(mapPoint);
}
mMap.addPolyline(polyline.color(Color.RED));
mMap.animateCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), 0));
} catch (XmlPullParserException | IOException e) {
e.printStackTrace();
toastException(e);
}
}