implement show route info
git-svn-id: https://osmand.googlecode.com/svn/trunk@385 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
parent
58e3dc675e
commit
5caaa1a60d
3 changed files with 55 additions and 8 deletions
|
@ -10,16 +10,16 @@ public class ToDoConstants {
|
|||
|
||||
// TODO ANDROID 0.3
|
||||
// Improvements
|
||||
// 1. Show layers (?) -
|
||||
// 0) map 1) transport (+) 2) Poi (choose filter) (+) 3) osm bugs (+) 3) Favorites(+)
|
||||
// 4) Route (gmaps) - 5) Transport route -
|
||||
// 1. Show layers (?) (+)
|
||||
// 0) map + 1) transport (+) 2) Poi (choose filter) (+) 3) osm bugs (+) 3) Favorites(+)
|
||||
// 4) Route (gmaps) + 5) Transport route -
|
||||
// and remove from settings (+)
|
||||
// 1.4 show detailed route on the map with turns and show route information directly (like in gmaps)
|
||||
// 1.4 show detailed route on the map with turns and show route information directly (like in gmaps) (+)
|
||||
|
||||
// 2. Using NameFinder to search online -
|
||||
// 3. Show route info after route calc (+)
|
||||
// 4. show vehicle for calculating route (+)
|
||||
// 5. Add zorders list to OsmandMapView
|
||||
// 5. Add zorders list to OsmandMapView (+)
|
||||
|
||||
// BUGS
|
||||
// ISSUE 21. (+, +, +)
|
||||
|
|
|
@ -359,12 +359,12 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
}
|
||||
|
||||
for (OsmandMapLayer layer : layers) {
|
||||
canvas.restore();
|
||||
canvas.save();
|
||||
if (!layer.drawInScreenPixels()) {
|
||||
canvas.rotate(rotate, w, h);
|
||||
}
|
||||
layer.onDraw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,15 +4,19 @@ import java.util.List;
|
|||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Paint.Style;
|
||||
import android.location.Location;
|
||||
import android.os.Handler;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.FrameLayout.LayoutParams;
|
||||
|
||||
import com.osmand.activities.RoutingHelper;
|
||||
import com.osmand.activities.ShowRouteInfoActivity;
|
||||
|
@ -21,6 +25,7 @@ import com.osmand.activities.RoutingHelper.RouteDirectionInfo;
|
|||
|
||||
public class RouteInfoLayer implements OsmandMapLayer, IRouteInformationListener {
|
||||
|
||||
private final int TEXT_SIZE = 150;
|
||||
|
||||
private OsmandMapTileView view;
|
||||
private final RoutingHelper routingHelper;
|
||||
|
@ -30,10 +35,14 @@ public class RouteInfoLayer implements OsmandMapLayer, IRouteInformationListener
|
|||
private Handler uiHandler;
|
||||
private boolean visible = true;
|
||||
private RectF border;
|
||||
private RectF textBorder;
|
||||
private Paint paintBorder;
|
||||
private Paint paintBlack;
|
||||
private final LinearLayout layout;
|
||||
private int directionInfo = -1;
|
||||
private TextView textView;
|
||||
|
||||
private Paint paintLightBorder;
|
||||
|
||||
public RouteInfoLayer(RoutingHelper routingHelper, LinearLayout layout){
|
||||
this.routingHelper = routingHelper;
|
||||
|
@ -54,7 +63,12 @@ public class RouteInfoLayer implements OsmandMapLayer, IRouteInformationListener
|
|||
if(routingHelper.getRouteDirections() != null && directionInfo > 0){
|
||||
directionInfo--;
|
||||
if(routingHelper.getRouteDirections().size() > directionInfo){
|
||||
Location l = routingHelper.getLocationFromRouteDirection(routingHelper.getRouteDirections().get(directionInfo));
|
||||
RouteDirectionInfo info = routingHelper.getRouteDirections().get(directionInfo);
|
||||
Location l = routingHelper.getLocationFromRouteDirection(info);
|
||||
if(info.descriptionRoute != null){
|
||||
textView.setText(info.descriptionRoute);
|
||||
textView.layout(0, 0, TEXT_SIZE, (int) ((textView.getPaint().getTextSize()+4) * textView.getLineCount()));
|
||||
}
|
||||
view.getAnimatedDraggingThread().startMoving(view.getLatitude(), view.getLongitude(),
|
||||
l.getLatitude(), l.getLongitude(),
|
||||
view.getZoom(), view.getZoom(), view.getSourceTileSize(), view.getRotate(), true);
|
||||
|
@ -71,7 +85,12 @@ public class RouteInfoLayer implements OsmandMapLayer, IRouteInformationListener
|
|||
public void onClick(View v) {
|
||||
if(routingHelper.getRouteDirections() != null && directionInfo < routingHelper.getRouteDirections().size() - 1){
|
||||
directionInfo++;
|
||||
Location l = routingHelper.getLocationFromRouteDirection(routingHelper.getRouteDirections().get(directionInfo));
|
||||
RouteDirectionInfo info = routingHelper.getRouteDirections().get(directionInfo);
|
||||
Location l = routingHelper.getLocationFromRouteDirection(info);
|
||||
if(info.descriptionRoute != null){
|
||||
textView.setText(info.descriptionRoute);
|
||||
textView.layout(0, 0, TEXT_SIZE, (int) ((textView.getPaint().getTextSize() + 4) * textView.getLineCount()));
|
||||
}
|
||||
view.getAnimatedDraggingThread().startMoving(view.getLatitude(), view.getLongitude(),
|
||||
l.getLatitude(), l.getLongitude(),
|
||||
view.getZoom(), view.getZoom(), view.getSourceTileSize(), view.getRotate(), true);
|
||||
|
@ -114,10 +133,23 @@ public class RouteInfoLayer implements OsmandMapLayer, IRouteInformationListener
|
|||
paintBorder = new Paint();
|
||||
paintBorder.setARGB(220, 160, 160, 160);
|
||||
paintBorder.setStyle(Style.FILL);
|
||||
paintLightBorder = new Paint();
|
||||
paintLightBorder.setARGB(130, 220, 220, 220);
|
||||
paintLightBorder.setStyle(Style.FILL);
|
||||
paintBlack = new Paint();
|
||||
paintBlack.setARGB(255, 0, 0, 0);
|
||||
paintBlack.setStyle(Style.STROKE);
|
||||
paintBlack.setAntiAlias(true);
|
||||
|
||||
textView = new TextView(view.getContext());
|
||||
LayoutParams lp = new LayoutParams(TEXT_SIZE, LayoutParams.WRAP_CONTENT);
|
||||
textView.setLayoutParams(lp);
|
||||
textView.setTextSize(16);
|
||||
textView.setTextColor(Color.argb(255, 0, 0, 0));
|
||||
textView.setMinLines(1);
|
||||
textView.setMaxLines(4);
|
||||
textView.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
textBorder = new RectF(-2, -1, TEXT_SIZE + 2, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -130,11 +162,26 @@ public class RouteInfoLayer implements OsmandMapLayer, IRouteInformationListener
|
|||
if(dir != null && directionInfo < dir.size() && directionInfo >= 0){
|
||||
canvas.rotate(view.getRotate(), view.getCenterPointX(), view.getCenterPointY());
|
||||
RouteDirectionInfo info = dir.get(directionInfo);
|
||||
|
||||
Location loc = routingHelper.getLocationFromRouteDirection(info);
|
||||
int x = view.getRotatedMapXForPoint(loc.getLatitude(), loc.getLongitude());
|
||||
int y = view.getRotatedMapYForPoint(loc.getLatitude(), loc.getLongitude());
|
||||
canvas.drawCircle(x, y, 5, paintBorder);
|
||||
canvas.drawCircle(x, y, 5, paintBlack);
|
||||
|
||||
if (textView.getText().length() > 0) {
|
||||
canvas.translate(x - textView.getWidth() / 2, y - textView.getHeight() - 12);
|
||||
int c = textView.getLineCount();
|
||||
textBorder.bottom = textView.getHeight() + 2;
|
||||
canvas.drawRect(textBorder, paintLightBorder);
|
||||
canvas.drawRect(textBorder, paintBlack);
|
||||
textView.draw(canvas);
|
||||
if (c == 0) {
|
||||
// special case relayout after on draw method
|
||||
textView.layout(0, 0, TEXT_SIZE, (int) ((textView.getPaint().getTextSize() + 4) * textView.getLineCount()));
|
||||
view.refreshMap();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue