public void recieveLongClick(MotionEvent ev) { Projection p = mapView.getProjection(); GeoPoint geoPoint = p.fromPixels((int) ev.getX(), (int) ev.getY()); // You can now pull lat/lng from geoPoint }
private void redrawPath(final MapView mv) { final Projection prj = mv.getProjection(); path.rewind(); final Iterator<GeoPoint> it = mOverlays.iterator(); prj.toPixels(it.next(), p); path.moveTo(p.x, p.y); while (it.hasNext()) { prj.toPixels(it.next(), p); path.lineTo(p.x, p.y); } path.setLastPoint(p.x, p.y); }
private void moveByPixels(int x, int y) { Point center = getProjection().toPixels(mapCenter, null); center.offset(x, y); mapCenter = getProjection().fromPixels(center.x, center.y); }
private void redrawPath(final MapView mv) { final Projection prj = mv.getProjection(); path.rewind(); final Iterator<GeoPoint> it = mOverlays.iterator(); prj.toPixels(it.next(), p); path.moveTo(p.x, p.y); while (it.hasNext()) { prj.toPixels(it.next(), p); path.lineTo(p.x, p.y); } path.setLastPoint(p.x, p.y); }
@Override public void draw(Canvas canvas, MapView mapView, boolean shadow) { super.draw(canvas, mapView, shadow); Point screenPoint = new Point(); mMapView.getProjection().toPixels(gp, screenPoint); canvas.drawBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.ic_maps_indicator_current_position), screenPoint.x, screenPoint.y - 8, null); // -8 as image is 16px high } }
if (Action == MotionEvent.ACTION_UP){ if(!moveMap) { Projection proj = myMapView.getProjection(); GeoPoint loc = proj.fromPixels((int)arg0.getX(), (int)arg0.getY()); //remove the last marker myMapView.getOverlays().remove(0); centerLocation(loc); }
void foo() { Projection proj = mapView.getProjection(); IGeoPoint p = proj.fromPixels(e.getX(), e.getY()); }
@Override public void draw(android.graphics.Canvas canvas, MapView mapView, boolean shadow) { super.draw(canvas, mapView, false); if (shadow == false) { //cycle through all overlays for (int index = 0; index < mOverlays.size(); index++) { OverlayItem item = mOverlays.get(index); // Converts lat/lng-Point to coordinates on the screen GeoPoint point = item.getPoint(); Point ptScreenCoord = new Point() ; mapView.getProjection().toPixels(point, ptScreenCoord); //show text to the right of the icon canvas.drawText(item.getTitle(), ptScreenCoord.x, ptScreenCoord.y+20, strokePaint); canvas.drawText(item.getTitle(), ptScreenCoord.x, ptScreenCoord.y+20, textPaint); } } }
Projection projection = mapView.getProjection(); GeoPoint g = projection.fromPixels((int)event.getX(),(int)event.getY());
final Projection pj = mapView.getProjection(); GeoPoint eventPosition = (GeoPoint) pj.fromPixels((int)event.getX(), (int)event.getY());
//rotate map map.setMapOrientation(angle); //center to current location GeoPoint point = mMyLocationNewOverlay.getMyLocation(); if (point == null) return; mapController.setCenter(point); //calculate translation float bottomPadding = map.getHeight() * 0.1f; float radius = map.getHeight()/2 - bottomPadding; double deltaW = Math.sin(Math.toRadians(angle)); double deltaH = Math.cos(Math.toRadians(angle)); int width = map.getWidth()/2 - (int)(radius * deltaW); int height = map.getHeight()/2 - (int)(radius * deltaH); //Move current location marker to bottom of the map Projection projection = map.getProjection(); GeoPoint centerPoint = (GeoPoint) projection.fromPixels(width, height); mapController.setCenter(centerPoint);
MapView mv = getMapView(); // fetch your map view Projection p = mv.getProjection(); GeoPoint point = p.fromPixels(X, Y); mc.animateTo(point);
onSingleTapUp(MotionEvent e, MapView mapView) { Projection proj = mapView.getProjection(); IGeoPoint p = proj.fromPixels(e.getX(), e.getY()); }
MapView map = (MapView) findViewById(R.id.youmapview); Projection proj = map.getProjection(); GeoPoint latlon = proj.fromPixels(x, y);
@Override public boolean onSingleTapConfirmed(MotionEvent e, MapView mapView) { Projection proj = mapView.getProjection(); p = (GeoPoint) proj.fromPixels((int) e.getX(), (int) e.getY()); proj = mapView.getProjection(); loc = (GeoPoint) proj.fromPixels((int) e.getX(), (int) e.getY()); String longitude = Double .toString(((double) loc.getLongitudeE6()) / 1000000); String latitude = Double .toString(((double) loc.getLatitudeE6()) / 1000000); Toast toast = Toast.makeText(getApplicationContext(), "Longitude: " + longitude + " Latitude: " + latitude, Toast.LENGTH_SHORT); toast.show(); return true; }
@Override public boolean dispatchTouchEvent(MotionEvent ev) { int actionType = ev.getAction(); switch (actionType) { case MotionEvent.ACTION_UP: Projection proj = mapView.getProjection(); GeoPoint loc = proj.fromPixels((int)ev.getX(), (int)ev.getY()); String longitude = Double.toString(((double)loc.getLongitudeE6())/1000000); String latitude = Double.toString(((double)loc.getLatitudeE6())/1000000); Toast toast = Toast.makeText(getApplicationContext(), "Longitude: "+ longitude +" Latitude: "+ latitude , Toast.LENGTH_LONG); toast.show(); } return super.dispatchTouchEvent(ev); }
@Override public boolean dispatchTouchEvent(MotionEvent ev) { int actionType = ev.getAction(); switch (actionType) { case MotionEvent.ACTION_UP: Projection proj = mapView.getProjection(); GeoPoint loc = proj.fromPixels((int)ev.getX(), (int)ev.getY()); String longitude = Double.toString(((double)loc.getLongitudeE6())/1000000); String latitude = Double.toString(((double)loc.getLatitudeE6())/1000000); Toast toast = Toast.makeText(getApplicationContext(), "Longitude: "+ longitude +" Latitude: "+ latitude , Toast.LENGTH_LONG); toast.show(); } return super.dispatchTouchEvent(ev); }
Projection proj = mapView.getProjection(); GeoPoint topLeft = proj.fromPixels(0, 0); GeoPoint bottomRight = proj.fromPixels(mapView.getWidth()-1, mapView.getHeight()-1); double topLat = topLeft.getLatitudeE6()/1E6; double topLon = topLeft.getLongitudeE6()/1E6; double bottomLat = bottomRight.getLatitudeE6()/1E6; double bottomLon = bottomRight.getLongitudeE6()/1E6;
Projection proj = mapView.getProjection(); GeoPoint topLeft = proj.fromPixels(0, 0); GeoPoint bottomRight = proj.fromPixels(mapView.getWidth()-1, mapView.getHeight()-1); double topLat = topLeft.getLatitudeE6()/1E6; double topLon = topLeft.getLongitudeE6()/1E6; double bottomLat = bottomRight.getLatitudeE6()/1E6; double bottomLon = bottomRight.getLongitudeE6()/1E6;