public MyOverlay(TextView lblCoords) { super(); coordinateLabel = lblCoords; } @Override public void draw(Canvas canvas, MapView mapView, boolean shadow) { super.draw(canvas, mapView, shadow); currentCenter = mapView.getMapCenter(); latitude = currentCenter.getLatitudeE6() / 1E6; longitude = currentCenter.getLatitudeE6() / 1E6; coordinateLabel.setText("lat: " + latitude + " long: " + longitude); }
public class CrosshairOverlay extends Overlay { public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) { Projection projection = mapView.getProjection(); Point center = projection.toPixels(mapView.getMapCenter(), null); // Customize appearance, should be a fields. Paint p = new Paint(Paint.ANTI_ALIAS_FLAG); p.setColor(0xFF000000); p.setStyle(Style.STROKE); p.setStrokeWidth(2.0f); int innerRadius = 10; int outerRadius = 20; canvas.drawCircle(center.x, center.y, innerRadius, p); canvas.drawCircle(center.x, center.y, outerRadius, p); return true; } }
public class CrossHairsOverlay extends Overlay { public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) { super.draw(canvas, mapView, shadow); GeoPoint centerGp = mapView.getMapCenter(); Projection projection = mapView.getProjection(); Point centerPoint = projection.toPixels(centerGp, null); Paint p = new Paint(); Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.crosshairs_dial); canvas.drawBitmap(bmp, centerPoint.x, centerPoint.y, p); return true; } }
public static void panMap (int x, int y, MapView map) { Point ptPixels = new Point(); GeoPoint geoPt = map.getMapCenter(); Projection projection = map.getProjection(); projection.toPixels(geoPt, ptPixels); ptPixels.x += x; ptPixels.y += y; geoPt = projection.fromPixels(ptPixels.x, ptPixels.y); map.getController().animateTo(geoPt); }
mapController = mapView.getController(); mapController.setZoom(14); // Zoom 1 is world view mapView.getMapCenter();
protected void backAndForth(MapView mv){ GeoPoint centreGpt = mv.getMapCenter(); int inLon = centreGpt.getLongitudeE6(); int inLat = centreGpt.getLatitudeE6(); Point p = new Point(); mv.getProjection().toPixels(centreGpt, p); GeoPoint backGpt = mv.getProjection().fromPixels(p.x, p.y); int outLat = backGpt.getLatitudeE6(); int outLon = backGpt.getLongitudeE6(); String res = "In lat " + inLat + " In lon " + inLon + " Out lat " + outLat + " Out lon " + outLon; Log.d("POS_TAG", res); }
GeoPoint newCenter = mapView.getMapCenter(); int minLat, maxLat, minLng, maxLng; minLat = mapCenter.getLatitudeE6() - mapView.getLatitudeSpan()/2; newCenter.getLongitudeE6() < minLng) mapCenter = mapView.getMapCenter(); Location mapCenterLoc = new Location(providerName); mapCenterLoc.setLatitude(newCenter.getLatitudeE6()/1E6);
GeoPoint center = mapView.getMapCenter(); int latSpan = mapView.getLatitudeSpan(); int longSpan = mapView.getLongitudeSpan();
GeoPoint center = mapView.getMapCenter(); int latSpan = mapView.getLatitudeSpan(); int longSpan = mapView.getLongitudeSpan();
GeoPoint p = mapView.getMapCenter(); OverlayItem overlayitem = new OverlayItem(p, "", ""); itemizedoverlay.addOverlay(overlayitem);