本文整理汇总了Java中com.mapbox.mapboxsdk.annotations.PolylineOptions类的典型用法代码示例。如果您正苦于以下问题:Java PolylineOptions类的具体用法?Java PolylineOptions怎么用?Java PolylineOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PolylineOptions类属于com.mapbox.mapboxsdk.annotations包,在下文中一共展示了PolylineOptions类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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));
}
}
开发者ID:mapbox,项目名称:mapbox-navigation-android,代码行数:22,代码来源:RerouteActivity.java
示例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));
}
开发者ID:metinkale38,项目名称:prayer-times-android,代码行数:21,代码来源:FragMap.java
示例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;
}
}
开发者ID:ralphpina,项目名称:ActivityMapper,代码行数:17,代码来源:MapFragment.java
示例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);
}
开发者ID:jawg,项目名称:osm-contributor,代码行数:21,代码来源:MapFragment.java
示例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));
}
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:18,代码来源:DirectionsActivity.java
示例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));
}
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:20,代码来源:SimplifyPolylineActivity.java
示例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));
}
开发者ID:opticod,项目名称:Moto-Navigator,代码行数:31,代码来源:MapFragment.java
示例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);
}
}
开发者ID:jawg,项目名称:osm-contributor,代码行数:11,代码来源:MapFragment.java
示例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();
}
开发者ID:jawg,项目名称:osm-contributor,代码行数:11,代码来源:MapFragment.java
示例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));
}
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:13,代码来源:SimplifyPolylineActivity.java
示例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));
}
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:13,代码来源:MapMatchingActivity.java
示例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));
}
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:13,代码来源:OptimizationActivity.java
示例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));
}
}
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:14,代码来源:DrawGeojsonLineActivity.java
示例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<>();
}
开发者ID:jawg,项目名称:osm-contributor,代码行数:6,代码来源:Way.java
示例15: getPolylineOptions
import com.mapbox.mapboxsdk.annotations.PolylineOptions; //导入依赖的package包/类
public PolylineOptions getPolylineOptions() {
return polylineOptions;
}
开发者ID:jawg,项目名称:osm-contributor,代码行数:4,代码来源:Way.java
示例16: removePolyline
import com.mapbox.mapboxsdk.annotations.PolylineOptions; //导入依赖的package包/类
private void removePolyline(PolylineOptions polylineOptions) {
if (polylineOptions != null) {
mapboxMap.removePolyline(polylineOptions.getPolyline());
}
}
开发者ID:jawg,项目名称:osm-contributor,代码行数:6,代码来源:MapFragment.java
示例17: getRouteLineList
import com.mapbox.mapboxsdk.annotations.PolylineOptions; //导入依赖的package包/类
public HashMap<String,ArrayList<PolylineOptions>> getRouteLineList()
{
return mRouteLineList;
}
开发者ID:geolys,项目名称:geolys-android-sdk,代码行数:5,代码来源:RouteHelper.java
示例18: onPostExecute
import com.mapbox.mapboxsdk.annotations.PolylineOptions; //导入依赖的package包/类
@Override
protected void onPostExecute(final List<LatLng> points) {
super.onPostExecute(points);
// Make sure our list isn't empty.
if (points.size() > 0) {
LatLng[] pointsArray = points.toArray(new LatLng[points.size()]);
// Draw a polyline showing the route the marker will be taking.
map.addPolyline(new PolylineOptions()
.add(pointsArray)
.color(Color.parseColor("#F13C6E"))
.width(4));
// We are using a custom marker icon.
Icon icon = IconFactory.getInstance(MarkerFollowingRouteActivity.this).fromResource(R.drawable.pink_dot);
// Using a view marker, we place it at the first point in the points list.
final Marker marker = map.addMarker(new MarkerViewOptions()
.position(points.get(count))
.icon(icon)
.anchor(0.5f, 0.5f)
.flat(true));
// Animating the marker requires the use of both the ValueAnimator and a handler.
// The ValueAnimator is used to move the marker between the GeoJSON points, this is
// done linearly. The handler is used to move the marker along the GeoJSON points.
handler = new Handler();
runnable = new Runnable() {
@Override
public void run() {
// Check if we are at the end of the points list, if so we want to stop using
// the handler.
if ((points.size() - 1) > count) {
// Calculating the distance is done between the current point and next.
// This gives us the duration we will need to execute the ValueAnimator.
// Multiplying by ten is done to slow down the marker speed. Adjusting
// this value will result in the marker traversing faster or slower along
// the line
distance = (long) marker.getPosition().distanceTo(points.get(count)) * 10;
// animate the marker from it's current position to the next point in the
// points list.
ValueAnimator markerAnimator = ObjectAnimator.ofObject(marker, "position",
new LatLngEvaluator(), marker.getPosition(), points.get(count));
markerAnimator.setDuration(distance);
markerAnimator.setInterpolator(new LinearInterpolator());
markerAnimator.start();
// This line will make sure the marker appears when it is being animated
// and starts outside the current user view. Without this, the user must
// intentionally execute a gesture before the view marker reappears on
// the map.
map.getMarkerViewManager().update();
// Keeping the current point count we are on.
count++;
// Once we finish we need to repeat the entire process by executing the
// handler again once the ValueAnimator is finished.
handler.postDelayed(this, distance);
}
}
};
handler.post(runnable);
}
}
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:70,代码来源:MarkerFollowingRouteActivity.java
注:本文中的com.mapbox.mapboxsdk.annotations.PolylineOptions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论