本文整理汇总了Java中com.mapbox.mapboxsdk.annotations.PolylineOptions类的典型用法代码示例。如果您正苦于以下问题:Java PolylineOptions类的具体用法?Java PolylineOptions怎么用?Java PolylineOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PolylineOptions类属于com.mapbox.mapboxsdk.annotations包,在下文中一共展示了PolylineOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawRoute
import com.mapbox.mapboxsdk.annotations.PolylineOptions; //导入依赖的package包/类
private void drawRoute(DirectionsRoute route) {
List<LatLng> points = new ArrayList<>();
List<Point> coords = LineString.fromPolyline(route.geometry(), Constants.PRECISION_6).coordinates();
for (Point point : coords) {
points.add(new LatLng(point.latitude(), point.longitude()));
}
if (!points.isEmpty()) {
if (polyline != null) {
mapboxMap.removePolyline(polyline);
}
// Draw polyline on map
polyline = mapboxMap.addPolyline(new PolylineOptions()
.addAll(points)
.color(Color.parseColor("#4264fb"))
.width(5));
}
}
示例2: onMyLocationChange
import com.mapbox.mapboxsdk.annotations.PolylineOptions; //导入依赖的package包/类
@Override
public void onMyLocationChange(@Nullable Location location) {
LatLng pos = new LatLng(location.getLatitude(), location.getLongitude());
if (mLine != null) {
mMap.removePolyline(mLine);
mMap.animateCamera(CameraUpdateFactory.newLatLng(pos));
} else {
//zoom first time
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location.getLatitude(), location.getLongitude()), 15));
}
mLine = mMap.addPolyline(new PolylineOptions()
.add(pos)
.add(mKaabePos)
.color(Color.parseColor("#3bb2d0"))
.width(3));
}
示例3: setPolylineColor
import com.mapbox.mapboxsdk.annotations.PolylineOptions; //导入依赖的package包/类
private void setPolylineColor(PolylineOptions options, int lastType) {
switch (lastType) {
case IN_VEHICLE:
options.color(RED);
break;
case ON_BICYCLE:
options.color(BLUE);
break;
case WALKING:
options.color(YELLOW);
break;
case RUNNING:
options.color(GREEN);
break;
}
}
示例4: buildEditionPolygon
import com.mapbox.mapboxsdk.annotations.PolylineOptions; //导入依赖的package包/类
private void buildEditionPolygon() {
// Current selected poiNodeRef
PoiNodeRef currentPoiNodeRef = wayMarkerSelected.getPoiNodeRef();
// Polyline related to this poiNodeRef
PolylineOptions currentPolyline = polylinesWays.get(currentPoiNodeRef.getId());
// Item of the poiNodeRef in the polilyne
int indexOfPoiNodeRef = currentPolyline.getPoints().indexOf(new LatLng(currentPoiNodeRef.getLatitude(), currentPoiNodeRef.getLongitude()));
LatLng previousPoint = currentPolyline.getPoints().get(indexOfPoiNodeRef == 0 ? indexOfPoiNodeRef + 1 : indexOfPoiNodeRef - 1);
LatLng nextPoint =
currentPolyline.getPoints().get(indexOfPoiNodeRef == currentPolyline.getPoints().size() - 1 ? indexOfPoiNodeRef - 1 : indexOfPoiNodeRef + 1);
editionPolyline = new PolylineOptions().add(previousPoint, currentPolyline.getPoints().get(indexOfPoiNodeRef), nextPoint)
.alpha(0.4f)
.width(1.8f)
.color(Color.parseColor("#F57C00"));
mapboxMap.addPolyline(editionPolyline);
}
示例5: drawRoute
import com.mapbox.mapboxsdk.annotations.PolylineOptions; //导入依赖的package包/类
private void drawRoute(DirectionsRoute route) {
// Convert LineString coordinates into LatLng[]
LineString lineString = LineString.fromPolyline(route.getGeometry(), PRECISION_6);
List<Position> coordinates = lineString.getCoordinates();
LatLng[] points = new LatLng[coordinates.size()];
for (int i = 0; i < coordinates.size(); i++) {
points[i] = new LatLng(
coordinates.get(i).getLatitude(),
coordinates.get(i).getLongitude());
}
// Draw Points on MapView
map.addPolyline(new PolylineOptions()
.add(points)
.color(Color.parseColor("#009688"))
.width(5));
}
示例6: drawSimplify
import com.mapbox.mapboxsdk.annotations.PolylineOptions; //导入依赖的package包/类
private void drawSimplify(List<Position> points) {
Position[] before = new Position[points.size()];
for (int i = 0; i < points.size(); i++) {
before[i] = points.get(i);
}
Position[] after = PolylineUtils.simplify(before, 0.001);
LatLng[] result = new LatLng[after.length];
for (int i = 0; i < after.length; i++) {
result[i] = new LatLng(after[i].getLatitude(), after[i].getLongitude());
}
map.addPolyline(new PolylineOptions()
.add(result)
.color(Color.parseColor("#3bb2d0"))
.width(4));
}
示例7: drawRoute
import com.mapbox.mapboxsdk.annotations.PolylineOptions; //导入依赖的package包/类
private void drawRoute(DirectionsRoute route, String profile) {
// Convert LineString coordinates into LatLng[]
LineString lineString = LineString.fromPolyline(route.getGeometry(), Constants.OSRM_PRECISION_V5);
List<Position> coordinates = lineString.getCoordinates();
LatLng[] points = new LatLng[coordinates.size()];
for (int i = 0; i < coordinates.size(); i++) {
points[i] = new LatLng(
coordinates.get(i).getLatitude(),
coordinates.get(i).getLongitude());
}
// Draw Points on MapView
int color;
if (profile.equals(DirectionsCriteria.PROFILE_CYCLING)) {
color = ContextCompat.getColor(mActivity, R.color.polyBike);
} else if (profile.equals(DirectionsCriteria.PROFILE_DRIVING)) {
color = ContextCompat.getColor(mActivity, R.color.polyCar);
} else {
color = ContextCompat.getColor(mActivity, R.color.polyWalk);
}
if (routePolyLine != null) {
map.removePolyline(routePolyLine);
}
routePolyLine = map.addPolyline(new PolylineOptions()
.add(points)
.color(color)
.width(5));
}
示例8: onCameraChangeUpdatePolyline
import com.mapbox.mapboxsdk.annotations.PolylineOptions; //导入依赖的package包/类
public void onCameraChangeUpdatePolyline() {
if (editionPolyline != null) {
List<LatLng> points = editionPolyline.getPoints();
points.set(1, mapboxMap.getCameraPosition().target);
removePolyline(editionPolyline);
editionPolyline = new PolylineOptions().addAll(points).alpha(0.4f).width(1.8f).color(Color.parseColor("#F57C00"));
mapboxMap.addPolyline(editionPolyline);
}
}
示例9: clearAllNodeRef
import com.mapbox.mapboxsdk.annotations.PolylineOptions; //导入依赖的package包/类
private void clearAllNodeRef() {
for (WayMarkerOptions locationMarker : markersNodeRef.values()) {
removeWayMarker(locationMarker);
}
for (PolylineOptions polylineOptions : polylinesWays.values()) {
removePolyline(polylineOptions);
}
markersNodeRef.clear();
polylinesWays.clear();
}
示例10: drawBeforeSimplify
import com.mapbox.mapboxsdk.annotations.PolylineOptions; //导入依赖的package包/类
private void drawBeforeSimplify(List<Position> points) {
LatLng[] pointsArray = new LatLng[points.size()];
for (int i = 0; i < points.size(); i++) {
pointsArray[i] = new LatLng(points.get(i).getLatitude(), points.get(i).getLongitude());
}
map.addPolyline(new PolylineOptions()
.add(pointsArray)
.color(Color.parseColor("#8a8acb"))
.width(4));
}
示例11: drawBeforeMapMatching
import com.mapbox.mapboxsdk.annotations.PolylineOptions; //导入依赖的package包/类
private void drawBeforeMapMatching(List<Position> points) {
LatLng[] pointsArray = new LatLng[points.size()];
for (int i = 0; i < points.size(); i++) {
pointsArray[i] = new LatLng(points.get(i).getLatitude(), points.get(i).getLongitude());
}
map.addPolyline(new PolylineOptions()
.add(pointsArray)
.color(Color.parseColor("#8a8acb"))
.alpha(0.65f)
.width(4));
}
示例12: drawOptimizedRoute
import com.mapbox.mapboxsdk.annotations.PolylineOptions; //导入依赖的package包/类
private void drawOptimizedRoute(DirectionsRoute route) {
// Remove old polyline
if (optimizedPolyline != null) {
mapboxMap.removePolyline(optimizedPolyline);
}
// Draw points on MapView
LatLng[] pointsToDraw = convertLineStringToLatLng(route);
optimizedPolyline = mapboxMap.addPolyline(new PolylineOptions()
.add(pointsToDraw)
.color(Color.parseColor(TEAL_COLOR))
.width(POLYLINE_WIDTH));
}
示例13: onPostExecute
import com.mapbox.mapboxsdk.annotations.PolylineOptions; //导入依赖的package包/类
@Override
protected void onPostExecute(List<LatLng> points) {
super.onPostExecute(points);
if (points.size() > 0) {
// Draw polyline on map
mapboxMap.addPolyline(new PolylineOptions()
.addAll(points)
.color(Color.parseColor("#3bb2d0"))
.width(2));
}
}
示例14: Way
import com.mapbox.mapboxsdk.annotations.PolylineOptions; //导入依赖的package包/类
public Way(Poi poi) {
this.poi = poi;
polylineOptions = new PolylineOptions().alpha(0.8f).width(1.8f).color(Color.parseColor("#1565C0"));
poiNodeRefs = new HashSet<>();
}
示例15: getPolylineOptions
import com.mapbox.mapboxsdk.annotations.PolylineOptions; //导入依赖的package包/类
public PolylineOptions getPolylineOptions() {
return polylineOptions;
}