MapView mapView = (MapView) findViewById(R.id.mapview); //or you can declare it directly with the API key Route route = directions(new GeoPoint((int)(26.2*1E6),(int)(50.6*1E6)), new GeoPoint((int)(26.3*1E6),(int)(50.7*1E6))); RouteOverlay routeOverlay = new RouteOverlay(route, Color.BLUE); mapView.getOverlays().add(routeOverlay); mapView.invalidate();
listOfOverlays.clear(); listOfOverlays.add(mapOverlay); mapView.invalidate(); }; };
mapview.invalidate();
MapView mapView = (MapView) findViewById(R.id.mapView); MapController mc = mapView.getController(); String coordinates[] = {"currentLat", "currentLat"}; double lat = Double.parseDouble(coordinates[0]); double lng = Double.parseDouble(coordinates[1]); p = new GeoPoint( (int) (lat * 1E6), (int) (lng * 1E6)); mc.animateTo(p); mc.setZoom(17); //Your zoom level in int mapView.invalidate();
MapView map = (MapView) findViewById(R.id.mapview); MapController mapController = map.getController(); List<Overlay> overlays = map.getOverlays(); overlays.add(new DrawableMapOverlay(this, point, R.drawable.my_drawable); map.invalidate(); Editors
mMapView.invalidate();
MapView mapView = new MapView(this, mapkey); MapController mc=mapView.getController(); GeoPoint myLocation = null; Drawable drawable = this.getResources().getDrawable(R.drawable.map_marker); myItemizedOverlay itemizedoverlay = new myItemizedOverlay(drawable, this); GeoPoint ppoint = new GeoPoint(platt,plngg); //platt and plngg xml parser value lattitude and Longitude OverlayItem poverlayitem = new OverlayItem(ppoint,bankname,name of the place); itemizedoverlay.addOverlay(poverlayitem); mapOverlays.add(itemizedoverlay); myLocation = new GeoPoint(platt,plngg); mc.animateTo(myLocation); mapView.setBuiltInZoomControls(true); mapView.setClickable(true); mc.setZoom(14); mapView.invalidate(); return mapView;
class MyActivity extends MapActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // your code here MapView map = findViewById(R.id.map); // you can change this MOverlay clickCatcher = new MOverlay(); List<Overlay> allOverlays = map.getOverlays(); allOverlays.add(clickCatcher); map.invalidate(); // All done! } }
public boolean onTouchEvent(MotionEvent event, MapView mapView) { if (event.getAction() == 1) { GeoPoint p = mapView.getProjection().fromPixels( (int) event.getX(), (int) event.getY()); Toast.makeText(getBaseContext(), p.getLatitudeE6() / 1E6 + "," + p.getLongitudeE6() /1E6 , Toast.LENGTH_SHORT).show(); mapView.getOverlays().add(new MarkerOverlay(p)); mapView.invalidate(); } return false; }
private MapView mapView; private MapController mc; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mapView = (MapView) findViewById(R.id.mapview1); mc = mapView.getController(); String coordinates[] = {"31.567615", "74.360962"}; double lat = Double.parseDouble(coordinates[0]); double lng = Double.parseDouble(coordinates[1]); GeoPoint p = new GeoPoint( (int) (lat * 1E6), (int) (lng * 1E6)); mc.animateTo(p); mc.setZoom(7); mapView.invalidate(); }
public boolean onTouchEvent(MotionEvent event, final MapView mapView) { final int action=event.getAction(); final int x=(int)event.getX(); final int y=(int)event.getY(); result = false; if (action==MotionEvent.ACTION_DOWN) { downPressed = true; drag = false; result = false; }else if (action==MotionEvent.ACTION_MOVE) { downPressed = false; drag=true; }else if (action==MotionEvent.ACTION_UP) { if(downPressed){ if(task.equals(SINGLE_LOCATION) | isDirectionPoint | mapView.isStreetView()){ tempPoint = mapView.getProjection().fromPixels(x, y); mapView.invalidate(); } } drag = false; downPressed = false; } return(result | super.onTouchEvent(event, mapView)); }
public boolean onTouchEvent(MotionEvent event, MapView mapView) { if (event.getAction() == 1) { GeoPoint p = mapView.getProjection().fromPixels( (int) event.getX(), (int) event.getY()); Toast.makeText(getBaseContext(), "lat and longtd is \n "+ p.getLatitudeE6() / 1E6 + "," + p.getLongitudeE6() /1E6 , Toast.LENGTH_LONG).show(); // mapView.getOverlays().add(new MarkerOverlay(p)); mapView.invalidate(); } return true; }
public boolean onTouchEvent(MotionEvent event, MapView mapView) { if (event.getAction() == 1) { GeoPoint p = mapView.getProjection().fromPixels( (int) event.getX(), (int) event.getY()); Toast.makeText(getBaseContext(), "lat and longtd is \n "+ p.getLatitudeE6() / 1E6 + "," + p.getLongitudeE6() /1E6 , Toast.LENGTH_LONG).show(); // mapView.getOverlays().add(new MarkerOverlay(p)); mapView.invalidate(); } return true; }
public void draw(Canvas canvas, MapView mapv, boolean shadow){ super.draw(canvas, mapv, shadow); Projection projection = mapv.getProjection(); Path p = new Path(); for (int i = 0; i < geoPointsArray.size(); i++) { if (i == geoPointsArray.size() - 1) { break; } Point from = new Point(); Point to = new Point(); projection.toPixels(geoPointsArray.get(i), from); projection.toPixels(geoPointsArray.get(i + 1), to); p.moveTo(from.x, from.y); p.lineTo(to.x, to.y); } Paint mPaint = new Paint(); mPaint.setStyle(Style.STROKE); mPaint.setColor(Color.GREEN); mPaint.setAntiAlias(true); mPaint.setStrokeWidth(5); canvas.drawPath(p, mPaint); mapv.invalidate(); super.draw(canvas, mapv, shadow); }//draw()
public void draw(Canvas canvas, MapView mapv, boolean shadow){ super.draw(canvas, mapv, shadow); Projection projection = mapv.getProjection(); Path p = new Path(); for (int i = 0; i < geoPointsArray.size(); i++) { if (i == geoPointsArray.size() - 1) { break; } Point from = new Point(); Point to = new Point(); projection.toPixels(geoPointsArray.get(i), from); projection.toPixels(geoPointsArray.get(i + 1), to); p.moveTo(from.x, from.y); p.lineTo(to.x, to.y); } Paint mPaint = new Paint(); mPaint.setStyle(Style.STROKE); mPaint.setColor(Color.GREEN); mPaint.setAntiAlias(true); mPaint.setStrokeWidth(5); canvas.drawPath(p, mPaint); mapv.invalidate(); super.draw(canvas, mapv, shadow); }//draw()
public void drawOverlay(MapView mapView) { List<Overlay> mapOverlays = mapView.getOverlays(); mapOverlays.clear(); mapView.invalidate(); int zoomLevel = mapView.getZoomLevel(); Drawable drawable = this.getResources().getDrawable(R.drawable.myDrawable); ItemizedOverlay itemizedoverlay[] = new ItemizedOverlay[myList.size()]; for (int i = 0; i < myList.size(); i++) { Foo foo = myList.get(i); GeoPoint point = new GeoPoint((int)(foo.lattitude * 1E6), (int)(foo.longtitude * 1E6)); OverlayItem overlayItem = new OverlayItem(point, foo.titel, foo.description); itemizedoverlay[i].addOverlay(overlayItem); mapOverlays.add(itemizedoverlay[i]); } }
listOfOverlays.add(myItemizedOverlay); mapView.invalidate();
listOfOverlays.add(myItemizedOverlay); mapView.invalidate();
anotherItemizedIconOverlay = new ItemizedIconOverlay<OverlayItem>(getApplicationContext(), overlayArray,null); mapView.getOverlays().add(anotherItemizedIconOverlay); mapView.invalidate(); }else{ mapView.getOverlays().remove(anotherItemizedIconOverlay); mapView.invalidate(); anotherItemizedIconOverlay = new ItemizedIconOverlay<OverlayItem>(getApplicationContext(), overlayArray,null); mapView.getOverlays().add(anotherItemizedIconOverlay);
initMyLocation(); map.invalidate();