private Route directions(final GeoPoint start, final GeoPoint dest) { Parser parser; //https://developers.google.com/maps/documentation/directions/#JSON <- get api String jsonURL = "http://maps.googleapis.com/maps/api/directions/json?"; final StringBuffer sBuf = new StringBuffer(jsonURL); sBuf.append("origin="); sBuf.append(start.getLatitudeE6()/1E6); sBuf.append(','); sBuf.append(start.getLongitudeE6()/1E6); sBuf.append("&destination="); sBuf.append(dest.getLatitudeE6()/1E6); sBuf.append(','); sBuf.append(dest.getLongitudeE6()/1E6); sBuf.append("&sensor=true&mode=driving"); parser = new GoogleParser(sBuf.toString()); Route r = parser.parse(); return r; }
public void run() { final double lon = p.getLongitudeE6() / 1E6; final double lat = p.getLatitudeE6() / 1E6; final double alt = getAltitude(lon, lat); msg.append("Lon: ");
selectedLatitude = geoPoint.getLatitudeE6(); selectedLongitude = geoPoint.getLongitudeE6(); return super.onTap(geoPoint,mapView);
public float getDistanceInMiles(GeoPoint p1, GeoPoint p2) { double lat1 = ((double)p1.getLatitudeE6()) / 1e6; double lng1 = ((double)p1.getLongitudeE6()) / 1e6; double lat2 = ((double)p2.getLatitudeE6()) / 1e6; double lng2 = ((double)p2.getLongitudeE6()) / 1e6; float [] dist = new float[1]; Location.distanceBetween(lat1, lng1, lat2, lng2, dist); return dist[0] * 0.000621371192f; }
public class YourMapActivity extends MapActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mv = new EnhancedMapView(this, "<your Maps API key here>"); mv.setClickable(true); mv.setBuiltInZoomControls(true); mv.setOnZoomChangeListener(new EnhancedMapView.OnZoomChangeListener() { @Override public void onZoomChange(MapView view, int newZoom, int oldZoom) { Log.d("test", "zoom changed from " + oldZoom + " to " + newZoom); } } mv.setOnPanChangeListener(new EnhancedMapView.OnPanChangeListener() { public void onPanChange(MapView view, GeoPoint newCenter, GeoPoint oldCenter) { Log.d("test", "center changed from " + oldCenter.getLatitudeE6() + "," + oldCenter.getLongitudeE6() + " to " + newCenter.getLatitudeE6() + "," + newCenter.getLongitudeE6()); } } }
int minLat = Integer.MAX_VALUE; int minLong = Integer.MAX_VALUE; int maxLat = Integer.MIN_VALUE; int maxLong = Integer.MIN_VALUE; for( GeoPoint l : points ) { minLat = Math.min( l.getLatitudeE6(), minLat ); minLong = Math.min( l.getLongitudeE6(), minLong); maxLat = Math.max( l.getLatitudeE6(), maxLat ); maxLong = Math.max( l.getLongitudeE6(), maxLong ); } mapView.getController().zoomToSpan(Math.abs( minLat - maxLat ), Math.abs( minLong - maxLong ));
GeoPoint topLeft = this.getProjection().fromPixels(getLeft(), getTop()); GeoPoint bottomRight = this.getProjection().fromPixels(getRight(), getBottom()); int topLat = topLeft.getLatitudeE6(); int topLng = topLeft.getLongitudeE6(); int bottomLat = bottomRight.getLatitudeE6(); int bottomLng = bottomRight.getLongitudeE6();
int nPixles = 5; //number of pixels GeoPoint g0 = mapview.getProjection().fromPixels(0, mapview.getHeight()/2); GeoPoint g1 = mapview.getProjection().fromPixels(nPixles, mapview.getHeight()/2); float[] results = new float[1]; Location.distanceBetween(g0.getLatitudeE6()/1E6, g0.getLongitudeE6()/1E6, g1.getLatitudeE6(), g1.getLongitudeE6()/1E6, results); float distanceInMeters = results[0];
@Override public Point toPixels(GeoPoint geoPoint, Point point) { if (point == null) { point = new Point(); } point.y = scaleDegree(geoPoint.getLatitudeE6(), realView.getBottom(), realView.getTop(), mapCenter.getLatitudeE6(), latitudeSpan); point.x = scaleDegree(geoPoint.getLongitudeE6(), realView.getLeft(), realView.getRight(), mapCenter.getLongitudeE6(), longitudeSpan); return point; }
public boolean onTouchEvent(MotionEvent ev) { if (ev.getAction() == MotionEvent.ACTION_UP) { GeoPoint centerGeoPoint = this.getMapCenter(); if (currentCenter == null || (currentCenter.getLatitudeE6() != centerGeoPoint.getLatitudeE6()) || (currentCenter.getLongitudeE6() != centerGeoPoint.getLongitudeE6()) ) { firePanEvent(currentCenter, this.getMapCenter()); } currentCenter = this.getMapCenter(); } return super.onTouchEvent(ev); }
public MarkerOptions getMarker(GeoPoint point, int drawableId) { return new MarkerOptions() .position(new LatLng(point.getLatitudeE6() / 1000000.0, point.getLongitudeE6() / 1000000.0)) .icon(BitmapDescriptorFactory.fromResource(drawableId)); }
MapController mapControl = map.getController(); GeoPoint mapCenter = map.getMapCenter(); int latCenter = mapCenter.getLatitudeE6(); int longCenter = mapCenter.getLongitudeE6(); int latSpan = map.getLatitudeSpan(); int longSpan = map.getLongitudeSpan(); int latMax = latCenter + (latSpan / 2); int latMin = latCenter - (latSpan / 2); int longMax = longCenter + (longSpan / 2); int longMin = longCenter - (longSpan / 2);
if (action == MotionEvent.ACTION_UP && inDrag != null) { GeoPoint pt = map.getProjection().fromPixels( x - xDragTouchOffset, y - yDragTouchOffset); taplat = pt.getLatitudeE6() / 1E6; // latitude taplon = pt.getLongitudeE6() / 1E6; // longitude }
btn4.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (v == btn4) { GeoPoint p = mapView.getMapCenter(); GeoPoint z = new GeoPoint(p.getLatitudeE6(), p.getLongitudeE6() - 1000000); mc.animateTo(z); } } });
GeoPoint geoPoint=mapView.getMapCenter(); double division = 1000000.0; double latitude = (geoPoint.getLatitudeE6()/division); double longitude = (geoPoint.getLongitudeE6()/division); Drawable drawable = context.getResources().getDrawable(R.drawable.ic_launcher); itemizedoverlay = new MyItemizedOverlay(context, drawable); OverlayItem overlayitem = new OverlayItem(geoPoint, "Objetivo", ""); itemizedoverlay.addOverlay(overlayitem); if (itemizedoverlay.size() > 0) { mapView.getOverlays().add(itemizedoverlay); }
mapView.getGlobalVisibleRect(currentMapBoundsRect); GeoPoint point1 = projection.fromPixels(currentMapBoundsRect.centerX(), currentMapBoundsRect.centerY()); GeoPoint point2 = projection.fromPixels(currentMapBoundsRect.left, currentMapBoundsRect.top); float[] results2 = new float[3]; Location.distanceBetween(point1.getLatitudeE6()/1E6, point1.getLongitudeE6()/1E6, point2.getLatitudeE6()/1E6, point2.getLongitudeE6()/1E6, results2);
GeoPoint pEast = position.destinationPoint(width, 90.0f); GeoPoint pSouthEast = pEast.destinationPoint(height, -180.0f); int north = position.getLatitudeE6()*2 - pSouthEast.getLatitudeE6(); int west = position.getLongitudeE6()*2 - pEast.getLongitudeE6(); BoundingBoxE6 bb = new BoundingBoxE6(north, pEast.getLongitudeE6(), pSouthEast.getLatitudeE6(), west);
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;
public Location GeoToLocation(GeoPoint gp) { Location location = new Location("dummyProvider"); location.setLatitude(gp.getLatitudeE6()/1E6); location.setLongitude(gp.getLongitudeE6()/1E6); return location; }