다음은지도에서 지오 포인트 사이의 경로를 그리는 코드입니다. 이것은 완벽하게 작동합니다. 내가 구현하려고하는 것은 선을 그리는 대신 iPhone에서와 같이 점 (.)으로이 경로를 표시하는 것입니다. gp1_ _ __ _ _gp2와 같이 한 줄로 그리는 대신 gp1이 gp1 ......... gp2가되도록하고 싶습니다.선 (________) 대신 점선 (....) 흔적 경로를 그리기
나는 이것에 대한 거의 모든 옵션을 시도했지만 이것에 대한 성공은 없으며, 어느 누구도이 문제를 해결할 수 있습니까?
private void drawPath(List geoPoints, int color) {
List overlays = objMapView.getOverlays();
int loopcount = geoPoints.size() - 1;
for (int i = 0; i < loopcount; i++) {
GeoPoint p1 = (GeoPoint) geoPoints.get(i);
GeoPoint p2 = (GeoPoint) geoPoints.get(i + 1);
MyPathOverLay p = null;
/**** Marking the start and end of the trailpath ****/
if (i == 0) {
Bitmap bmp = BitmapFactory.decodeResource(this.getResources(),R.drawable.greenflag);
p = new MyPathOverLay(p1, p2, 0xFFFF0000, true, false, bmp);
} else if (i == loopcount - 1) {
Bitmap bmp = BitmapFactory.decodeResource(this.getResources(),R.drawable.redflag);
p = new MyPathOverLay(p1, p2, 0xFFFF0000, false, true, bmp);
} else {
p = new MyPathOverLay(p1, p2, 0xFFFF0000, false, false, null);
}
overlays.add(p);
}
}
public class MyPathOverLay extends Overlay {
private GeoPoint gp1;
private GeoPoint gp2;
private int color;
Boolean isFirstPOI;
Boolean isLastPOI;
AudioMap audioMap;
Bitmap bmp;
public MyPathOverLay(GeoPoint gp1, GeoPoint gp2, int color,Boolean first, Boolean last,Bitmap bitMap) {
this.gp1 = gp1;
this.gp2 = gp2;
this.color = color;
this.isFirstPOI= first;
this.isLastPOI = last;
this.bmp = bitMap;
}
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
Projection projection = mapView.getProjection();
Paint paint = new Paint();
Point point = new Point();
projection.toPixels(gp1, point);
paint.setColor(color);
Point point2 = new Point();
projection.toPixels(gp2, point2);
paint.setStrokeWidth(5);
paint.setAlpha(120);
canvas.drawLine(point.x, point.y, point2.x, point2.y, paint);
//---translate the GeoPoint to screen pixels---
Point screenPts = new Point();
mapView.getProjection().toPixels(gp1, screenPts);
//---translate the GeoPoint to screen pixels---
Point screenPts1 = new Point();
mapView.getProjection().toPixels(gp2, screenPts1);
if(isFirstPOI == true){
canvas.drawBitmap(bmp,screenPts.x-20,screenPts.y-40, null);
}
else if(isLastPOI == true) {
canvas.drawBitmap(bmp,screenPts1.x-20,screenPts1.y-35, null);
}
super.draw(canvas, mapView, shadow);
}
}이 사람에
http://stackoverflow.com/questions/6167236/canvas-drawlines-disjointed-segments – MKJParekh
이 퀘스트인가요? 이온은 이전 구글지도 api를 사용하여 (이 코멘트를 쓰는 순간, 현재 하나는 v2입니다)? – DNax