/** * Create overlay with a specific color * * @param colour A string with a hex colour value */ private PathOverlay createPathOverlay(String colour) { // CPSC 210 Students, you should not need to touch this method PathOverlay po = new PathOverlay(Color.parseColor(colour), getActivity()); Paint pathPaint = new Paint(); pathPaint.setColor(Color.parseColor(colour)); pathPaint.setStrokeWidth(4.0f); pathPaint.setStyle(Paint.Style.STROKE); po.setPaint(pathPaint); return po; }
/** * @see * com.brantapps.polaris.api.Mappable#addPolyline(com.brantapps.polaris.api.MapPolylineOptions) */ @Override public int addPolyline(final MapPolylineOptions<?> polylineOptions) { if (polylines == null) { polylines = new HashMap<Integer, PathOverlay>(); } final Polyline polyline = (Polyline) polylineOptions.get(); final PathOverlay overlay = new PathOverlay(polyline.color, polyline.width, getResourceProxy()); overlay.addPoints(polyline.points); mapView.getOverlays().add(0, overlay); // add polyline overlay below markers, etc final int id = random.nextInt(); polylines.put(id, overlay); return id; }
@Override protected void onPostExecute(SchedulePlot schedulePlot) { // CPSC 210 Students: This method should plot the route onto the map // with the given line colour specified in schedulePlot. If there is // no route to plot, a dialog box should be displayed. // To actually make something show on the map, you can use overlays. // For instance, the following code should show a line on a map // PathOverlay po = createPathOverlay("#FFFFFF"); // po.addPoint(point1); // one end of line // po.addPoint(point2); // second end of line // scheduleOverlay.add(po); // OverlayManager om = mapView.getOverlayManager(); // om.addAll(scheduleOverlay); // mapView.invalidate(); // cause map to redraw PathOverlay po = createPathOverlay(schedulePlot.getColourOfLine()); // plot buildings of the schedule plotBuildings(schedulePlot); // if there is no route, display no route if (schedulePlot.getRoute() == null) { AlertDialog aDialog = createSimpleDialog("NO ROUTE TO PLOT"); aDialog.show(); // otherwise plot the route } else { // get the list of geopoints of the schedulePlot List<GeoPoint> points = schedulePlot.getRoute(); for (GeoPoint point : points) { po.addPoint(point); } scheduleOverlay.add(po); OverlayManager om = mapView.getOverlayManager(); om.addAll(scheduleOverlay); mapView.invalidate(); } }