本文整理汇总了Java中com.baidu.mapapi.map.PolylineOptions类的典型用法代码示例。如果您正苦于以下问题:Java PolylineOptions类的具体用法?Java PolylineOptions怎么用?Java PolylineOptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PolylineOptions类属于com.baidu.mapapi.map包,在下文中一共展示了PolylineOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawTrailLines
import com.baidu.mapapi.map.PolylineOptions; //导入依赖的package包/类
private void drawTrailLines(List<LatLng> pointList) {
baiduMap.clear();
//把地图移动到point点
moveToLocation(pointList.get(pointList.size() / 2));
//绘制跑步开始标记
if (!pointList.isEmpty()) {
addMarker(pointList.get(0), R.drawable.ic_loc_start);
}
//绘制跑步结束标记
if (!pointList.isEmpty()) {
addMarker(pointList.get(pointList.size() - 1), R.drawable.ic_loc_end);
}
//画路径线
PolylineOptions polyline;
if (pointList.size() >= 2 && pointList.size() < 10000) {
polyline = new PolylineOptions()
.width(6)
.color(ContextCompat.getColor(this, R.color.colorPrimary))
.zIndex(0)
.points(pointList);
baiduMap.addOverlay(polyline);//添加Marker
}
}
示例2: drawRealtimePoint
import com.baidu.mapapi.map.PolylineOptions; //导入依赖的package包/类
/**
* 画出实时线路点
*
* @param point
*/
private void drawRealtimePoint(LatLng point) {
Log.i("TGA", "绘制成功");
mBaiduMap.clear();
MapStatus mapStatus = new MapStatus.Builder().target(point).zoom(18).build();
msUpdate = MapStatusUpdateFactory.newMapStatus(mapStatus);
realtimeBitmap = BitmapDescriptorFactory.fromResource(R.drawable.ct_map_location);
overlay = new MarkerOptions().position(point)
.icon(realtimeBitmap).zIndex(9).draggable(true);
if (pointList.size() >= 2 && pointList.size() <= 6000) {
polyline = new PolylineOptions().width(10).color(Color.GREEN).points(pointList);
}
addMarker();
}
示例3: onMapReady
import com.baidu.mapapi.map.PolylineOptions; //导入依赖的package包/类
@Override
public void onMapReady(GoogleMap googleMap) {
// Instantiates a new Polyline object and adds points to define a rectangle
com.google.android.gms.maps.model.PolylineOptions rectOptions = new com.google.android.gms.maps.model.PolylineOptions()
.add(new com.google.android.gms.maps.model.LatLng(-18.5186650000, 141.9748780000))
.add(new com.google.android.gms.maps.model.LatLng(-18.5186650000, 144.9748780000)) // North of the previous point, but at the same longitude
.add(new com.google.android.gms.maps.model.LatLng(-20.5186650000, 144.9748780000)) // Same latitude, and 30km to the west
.add(new com.google.android.gms.maps.model.LatLng(-20.5186650000, 141.9748780000)) // Same longitude, and 16km to the south
.add(new com.google.android.gms.maps.model.LatLng(-24.5186650000, 141.9748780000)); // Closes the polyline.
rectOptions.width(8)
.color(ContextCompat.getColor(getActivity(), R.color.red_500));
// Get back the mutable Polyline
com.google.android.gms.maps.model.Polyline polyline = googleMap.addPolyline(rectOptions);
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new com.google.android.gms.maps.model.LatLng(-18.5186650000, 141.9748780000), 6));
}
示例4: onCheckedChanged
import com.baidu.mapapi.map.PolylineOptions; //导入依赖的package包/类
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
switch (buttonView.getId()) {
case R.id.switchLBSTrace:
if (isChecked) {
polylineMyTrace = new PolylineOptions();
refreshMapUI();
mlistener.toolbarOperateCloseTrackOrOpenColor(true);
} else {
mlistener.toolbarOperateCloseTrackOrOpenColor(false);
}
break;
case R.id.switchLocation:
if (isChecked) {
baiduMap.setMyLocationConfigeration(new MyLocationConfiguration(MyLocationConfiguration.LocationMode.FOLLOWING, false, null));
baiduMap.animateMapStatus(MapStatusUpdateFactory.zoomTo(baiduMap.getMaxZoomLevel() - 2));
} else
baiduMap.setMyLocationConfigeration(new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, false, null));
break;
}
}
示例5: getOverlayOptions
import com.baidu.mapapi.map.PolylineOptions; //导入依赖的package包/类
@Override
public final List<OverlayOptions> getOverlayOptions() {
if (mBusLineResult == null || mBusLineResult.getStations() == null) {
return null;
}
List<OverlayOptions> overlayOptionses = new ArrayList<OverlayOptions>();
for (BusLineResult.BusStation station : mBusLineResult.getStations()) {
overlayOptionses.add(new MarkerOptions()
.position(station.getLocation())
.zIndex(10)
.anchor(0.5f, 0.5f)
.icon(BitmapDescriptorFactory
.fromAssetWithDpi("Icon_bus_station.png")));
}
List<LatLng> points = new ArrayList<LatLng>();
for (BusLineResult.BusStep step : mBusLineResult.getSteps()) {
if (step.getWayPoints() != null) {
points.addAll(step.getWayPoints());
}
}
if (points.size() > 0) {
overlayOptionses
.add(new PolylineOptions().width(10)
.color(Color.argb(178, 0, 78, 255)).zIndex(0)
.points(points));
}
return overlayOptionses;
}
示例6: drawCurrentPoint
import com.baidu.mapapi.map.PolylineOptions; //导入依赖的package包/类
/**
* 画出实时线路点
*
* @param point 最新线路点
*/
private void drawCurrentPoint(LatLng point) {
baiduMap.clear();
//把地图移动到point点
moveToLocation(point);
//绘制跑步开始标记
if (!pointList.isEmpty()) {
addMarker(pointList.get(0), R.drawable.ic_loc_start);
}
//画定位图标
if (runningStatus == 2) {
addMarker(point, R.drawable.ic_loc_end);
} else {
addMarker(point, R.drawable.ic_loc_normal);
}
//画路径线
polyline = null;
if (pointList.size() >= 2 && pointList.size() < 10000) {
polyline = new PolylineOptions()
.width(6)
.color(ContextCompat.getColor(this, R.color.colorPrimary))
.zIndex(0)
.points(pointList);
baiduMap.addOverlay(polyline);//添加Marker
} else if (pointList.size() >= 10000) {
startButton.callOnClick();
new AlertDialog.Builder(this)
.setTitle("超时提示")
.setMessage(R.string.over_time)
.setPositiveButton(R.string.got_it, null)
.create().show();
}
}
示例7: getOverlayOptions
import com.baidu.mapapi.map.PolylineOptions; //导入依赖的package包/类
@Override
public final List<OverlayOptions> getOverlayOptions() {
if (mBusLineResult == null || mBusLineResult.getStations() == null) {
return null;
}
List<OverlayOptions> overlayOptionses = new ArrayList<OverlayOptions>();
for (BusLineResult.BusStation station : mBusLineResult.getStations()) {
overlayOptionses.add(new MarkerOptions()
.position(station.getLocation())
.zIndex(10)
.anchor(0.5f, 0.5f)
.icon(BitmapDescriptorFactory
.fromAssetWithDpi("Icon_bus_station.png")));
}
List<LatLng> points = new ArrayList<LatLng>();
for (BusLineResult.BusStep step : mBusLineResult.getSteps()) {
if (step.getWayPoints() != null) {
points.addAll(step.getWayPoints());
}
}
if (points.size() > 0) {
overlayOptionses
.add(new PolylineOptions().width(10)
.color(Color.argb(178, 0, 78, 255)).zIndex(0)
.points(points));
}
return overlayOptionses;
}
示例8: addPolyline
import com.baidu.mapapi.map.PolylineOptions; //导入依赖的package包/类
@Override
public void addPolyline(final PolylineInfo polylineInfo) {
if (polylineInfo == null || polylineInfo.isOnMap()) {
return;
}
final PolylineOptions options = fromPolylineInfo(polylineInfo);
if (options == null) {
return;
}
Polyline polyline = (Polyline) getBaiduMap().addOverlay(options);
polylineInfo.setProxyPolyline(new ProxyMapPolyline(polyline));
polylinesMap.put(polyline, polylineInfo);
}
示例9: fromPolylineInfo
import com.baidu.mapapi.map.PolylineOptions; //导入依赖的package包/类
private PolylineOptions fromPolylineInfo(PolylineInfo info) {
List<LatLng> points = MapUtils.coordToBaiduLatLng(info.getPoints());
if (points.size() <= 1) {
return null;
}
return new PolylineOptions()
.points(points)
.color(info.getColor())
.visible(info.isVisible())
.width((int) info.getWidth())
.zIndex((int) info.getZIndex());
}
示例10: addCustomElementsDemo
import com.baidu.mapapi.map.PolylineOptions; //导入依赖的package包/类
public void addCustomElementsDemo(LatLng latLng1, LatLng latLng2) {
List<LatLng> points = new ArrayList<LatLng>();
points.add(latLng1);
points.add(latLng2);
OverlayOptions ooPolyline = new PolylineOptions().width(10)
.color(0xAAFF0000).points(points);
mBaiduMap.addOverlay(ooPolyline);
}
示例11: addCustomEleemntsDemo
import com.baidu.mapapi.map.PolylineOptions; //导入依赖的package包/类
public void addCustomEleemntsDemo(List<LatLng> latLngList) {
List<LatLng> points = new ArrayList<LatLng>();
points.addAll(latLngList);
OverlayOptions ooPolyline = new PolylineOptions().width(10)
.color(0xAAFF0000).points(points);
mBaiduMap.addOverlay(ooPolyline);
}
示例12: onCreate
import com.baidu.mapapi.map.PolylineOptions; //导入依赖的package包/类
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_route_detail);
setStatusBar();
route_detail_mapview = (MapView) findViewById(R.id.route_detail_mapview);
total_time = (TextView) findViewById(R.id.total_time);
total_distance = (TextView) findViewById(R.id.total_distance);
total_price = (TextView) findViewById(R.id.total_pricce);
routeBaiduMap = route_detail_mapview.getMap();
route_detail_mapview.showZoomControls(false);
startBmp = BitmapDescriptorFactory.fromResource(R.mipmap.route_start);
endBmp = BitmapDescriptorFactory.fromResource(R.mipmap.route_end);
initMap();
Intent intent = getIntent();
String time = intent.getStringExtra("totalTime");
String distance = intent.getStringExtra("totalDistance");
String price = intent.getStringExtra("totalPrice");
routePointsStr = intent.getStringExtra("routePoints");
routePoints = new Gson().fromJson(routePointsStr, new TypeToken<List<RoutePoint>>() {
}.getType());
List<LatLng> points = new ArrayList<LatLng>();
for (int i = 0; i < routePoints.size(); i++) {
RoutePoint point = routePoints.get(i);
LatLng latLng = new LatLng(point.getRouteLat(), point.getRouteLng());
Log.d("gaolei", "point.getRouteLat()----show-----" + point.getRouteLat());
Log.d("gaolei", "point.getRouteLng()----show-----" + point.getRouteLng());
points.add(latLng);
}
if (points.size() > 2) {
OverlayOptions ooPolyline = new PolylineOptions().width(10)
.color(0xFF36D19D).points(points);
routeBaiduMap.addOverlay(ooPolyline);
RoutePoint startPoint = routePoints.get(0);
LatLng startPosition = new LatLng(startPoint.getRouteLat(), startPoint.getRouteLng());
MapStatus.Builder builder = new MapStatus.Builder();
builder.target(startPosition).zoom(18.0f);
routeBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
RoutePoint endPoint = routePoints.get(routePoints.size() - 1);
LatLng endPosition = new LatLng(endPoint.getRouteLat(), endPoint.getRouteLng());
addOverLayout(startPosition, endPosition);
}
total_time.setText("骑行时长:" + time + "分钟");
total_distance.setText("骑行距离:" + distance + "米");
total_price.setText("余额支付:" + price + "元");
}
示例13: onCreate
import com.baidu.mapapi.map.PolylineOptions; //导入依赖的package包/类
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_route_detail);
route_detail_mapview = (MapView) findViewById(R.id.route_detail_mapview);
total_time = (TextView) findViewById(R.id.total_time);
total_distance = (TextView) findViewById(R.id.total_distance);
total_price = (TextView) findViewById(R.id.total_pricce);
routeBaiduMap = route_detail_mapview.getMap();
route_detail_mapview.showZoomControls(false);
startBmp = BitmapDescriptorFactory.fromResource(R.mipmap.route_start);
endBmp = BitmapDescriptorFactory.fromResource(R.mipmap.route_end);
initMap();
Intent intent = getIntent();
String time = intent.getStringExtra("totalTime");
String distance = intent.getStringExtra("totalDistance");
String price = intent.getStringExtra("totalPrice");
routePointsStr = intent.getStringExtra("routePoints");
routePoints = new Gson().fromJson(routePointsStr, new TypeToken<List<RoutePoint>>() {
}.getType());
savaDatas(time,distance,price);//yiwen add
List<LatLng> points = new ArrayList<LatLng>();
for (int i = 0; i < routePoints.size(); i++) {
RoutePoint point = routePoints.get(i);
LatLng latLng = new LatLng(point.getRouteLat(), point.getRouteLng());
Log.d("gaolei", "point.getRouteLat()----show-----" + point.getRouteLat());
Log.d("gaolei", "point.getRouteLng()----show-----" + point.getRouteLng());
points.add(latLng);
}
if (points.size() > 2) {
OverlayOptions ooPolyline = new PolylineOptions().width(10)
.color(0xFF36D19D).points(points);
routeBaiduMap.addOverlay(ooPolyline);
RoutePoint startPoint = routePoints.get(0);
LatLng startPosition = new LatLng(startPoint.getRouteLat(), startPoint.getRouteLng());
MapStatus.Builder builder = new MapStatus.Builder();
builder.target(startPosition).zoom(18.0f);
routeBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
RoutePoint endPoint = routePoints.get(routePoints.size() - 1);
LatLng endPosition = new LatLng(endPoint.getRouteLat(), endPoint.getRouteLng());
addOverLayout(startPosition, endPosition);
}
total_time.setText("骑行时长:" + time + "分钟");
total_distance.setText("骑行距离:" + distance + "米");
total_price.setText("余额支付:" + price + "元");
}
示例14: showBaiduMap
import com.baidu.mapapi.map.PolylineOptions; //导入依赖的package包/类
/**
* 加载轨迹数据至百度地图
*/
private void showBaiduMap(List<LocationDetail> locationDetails) {
if (locationDetails == null || locationDetails.size() == 0) return;
int countInCircle = 0;
List<LatLng> polylines = new ArrayList<>();
for (LocationDetail locationDetail :
locationDetails) {
if (locationDetail.isInvalid()) continue;
LatLng lng = locationDetail.getLatLng();
polylines.add(lng);
if (polylines.size() > 1) {
if (SpatialRelationUtil.isCircleContainsPoint(polylines.get(0), LOCATION_RADIUS, lng)) {
countInCircle++;
}
}
}
Collections.reverse(polylines); //按时间正序
OverlayOptions markerOptions = null;
if (polylines.size() > 1) {
OverlayOptions polylineOptions = new PolylineOptions()
.points(polylines)
.width(8)
.color(ContextCompat.getColor(getActivity(), R.color.red_500));
mVirtureRoad = (Polyline) mBaiduMap.addOverlay(polylineOptions);
markerOptions = new MarkerOptions().flat(true).anchor(0.5f, 0.5f).icon(BitmapDescriptorFactory
.fromResource(R.drawable.ic_car)).position(polylines.get(0)).rotate((float) getAngle(0));
} else {
markerOptions = new MarkerOptions().flat(true).anchor(0.5f, 0.5f).icon(BitmapDescriptorFactory
.fromResource(R.drawable.ic_car)).position(polylines.get(0));
}
mMoveMarker = (Marker) mBaiduMap.addOverlay(markerOptions);
//设置中心点
setBaiduMapAdaptedZoom(polylines);
if (polylines.size() > 1 && countInCircle < polylines.size() / 2) {
movingThread = new Thread(new MyThread());
movingThread.start();
}
}
示例15: showBaiduMap
import com.baidu.mapapi.map.PolylineOptions; //导入依赖的package包/类
@Override
public void showBaiduMap(List<LocationDetail> locationDetails) {
if (locationDetails == null || locationDetails.size() == 0) return;
int countInCircle = 0;
List<LatLng> polylines = new ArrayList<>();
for (LocationDetail locationDetail :
locationDetails) {
if (locationDetail.isInvalid()) continue;
LatLng lng = locationDetail.getLatLng();
polylines.add(lng);
if (polylines.size() > 1) {
if (SpatialRelationUtil.isCircleContainsPoint(polylines.get(0), LOCATION_RADIUS, lng)) {
countInCircle++;
}
}
}
Collections.reverse(polylines); //按时间正序
OverlayOptions markerOptions = null;
if (polylines.size() > 1) {
OverlayOptions polylineOptions = new PolylineOptions()
.points(polylines)
.width(8)
.color(ContextCompat.getColor(getActivity(), R.color.red_500));
mVirtureRoad = (Polyline) mBaiduMap.addOverlay(polylineOptions);
markerOptions = new MarkerOptions().flat(true).anchor(0.5f, 0.5f).icon(BitmapDescriptorFactory
.fromResource(R.drawable.ic_car)).position(polylines.get(0)).rotate((float) getAngle(0));
} else {
markerOptions = new MarkerOptions().flat(true).anchor(0.5f, 0.5f).icon(BitmapDescriptorFactory
.fromResource(R.drawable.ic_car)).position(polylines.get(0));
}
mMoveMarker = (Marker) mBaiduMap.addOverlay(markerOptions);
//设置中心点
setBaiduMapAdaptedZoom(polylines);
if (polylines.size() > 1 && countInCircle < polylines.size() / 2) {
movingThread = new Thread(new MyThread());
movingThread.start();
}
}