本文整理汇总了Java中com.google.android.gms.maps.GoogleMap.addPolyline方法的典型用法代码示例。如果您正苦于以下问题:Java GoogleMap.addPolyline方法的具体用法?Java GoogleMap.addPolyline怎么用?Java GoogleMap.addPolyline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.maps.GoogleMap
的用法示例。
在下文中一共展示了GoogleMap.addPolyline方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addInterval
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的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);
}
}
示例2: recapDisplayTrack
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
/**
* Display the given Track on the given GoogleMap. The argument color indicates the desired color for
* the Track to be shown. Also takes care to center the camera on the displayed Track. Used for recaps
*
* @param track Track to be shown
* @param googleMap map where the Track must be shown
* @param color color for the Track to be shown
*/
public static void recapDisplayTrack(Track track, GoogleMap googleMap, int color) {
if(track == null || googleMap == null) {
throw new IllegalArgumentException();
}
if (track.getTotalCheckPoints() != 0) {
// Build polyline and latitude, longitude bounds
PolylineOptions polylineOptions = new PolylineOptions();
List<CheckPoint> trackPoints = track.getCheckpoints();
LatLngBounds.Builder builder = new LatLngBounds.Builder();
for (CheckPoint checkPoint : trackPoints) {
LatLng latLng = new LatLng(checkPoint.getLatitude(), checkPoint.getLongitude());
polylineOptions.add(latLng);
builder.include(latLng);
}
googleMap.addPolyline(polylineOptions.color(color));
// Center camera on past run
LatLngBounds bounds = builder.build();
int padding = 40;
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBounds(bounds, padding);
googleMap.animateCamera(cameraUpdate);
}
}
示例3: drawRouteOnMap
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
private void drawRouteOnMap(GoogleMap map, List<LatLng> positions){
PolylineOptions options = new PolylineOptions().width(5).color(Color.RED).geodesic(true);
options.addAll(positions);
Polyline polyline = map.addPolyline(options);
}
示例4: addPolylineToMap
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
/**
* Add a Polyline to the map
*
* @param map
* @param polyline
* @return
*/
public static Polyline addPolylineToMap(GoogleMap map,
PolylineOptions polyline) {
return map.addPolyline(polyline);
}