int minLat = Integer.MAX_VALUE; int maxLat = Integer.MIN_VALUE; int minLon = Integer.MAX_VALUE; int maxLon = Integer.MIN_VALUE; for (GeoPoint item : items) { int lat = item.getLatitudeE6(); int lon = item.getLongitudeE6(); maxLat = Math.max(lat, maxLat); minLat = Math.min(lat, minLat); maxLon = Math.max(lon, maxLon); minLon = Math.min(lon, minLon); } mapController.zoomToSpan(Math.abs(maxLat - minLat), Math.abs(maxLon - minLon)); mapController.animateTo(new GeoPoint( (maxLat + minLat)/2, (maxLon + minLon)/2 ));
if (lngLat.length >= 2 && gp1.getLatitudeE6() > 0 && gp1.getLongitudeE6() > 0 && gp2.getLatitudeE6() > 0 && gp2.getLongitudeE6() > 0) { Log.d(myapp.APP, "draw:" + gp1.getLatitudeE6() + "/" + gp1.getLongitudeE6() + " TO " + gp2.getLatitudeE6() + "/" + gp2.getLongitudeE6());
public class OsmdroidDemoMap extends Activity { private MapView mMapView; private MapController mMapController; int mIncr = 10000; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.osm_main); mMapView = (MapView) findViewById(R.id.mapview); mMapView.setTileSource(TileSourceFactory.MAPNIK); mMapView.setBuiltInZoomControls(true); mMapView.setMultiTouchControls(true); mMapController = mMapView.getController(); mMapController.setZoom(13); GeoPoint gPt0 = new GeoPoint(51500000, -150000); GeoPoint gPt1 = new GeoPoint(gPt0.getLatitudeE6()+ mIncr, gPt0.getLongitudeE6()); GeoPoint gPt2 = new GeoPoint(gPt0.getLatitudeE6()+ mIncr, gPt0.getLongitudeE6() + mIncr); GeoPoint gPt3 = new GeoPoint(gPt0.getLatitudeE6(), gPt0.getLongitudeE6() + mIncr); mMapController.setCenter(gPt0); PathOverlay myPath = new PathOverlay(Color.RED, this); myPath.addPoint(gPt0); myPath.addPoint(gPt1); myPath.addPoint(gPt2); myPath.addPoint(gPt3); myPath.addPoint(gPt0); mMapView.getOverlays().add(myPath); } }
mc.animateTo(new GeoPoint( (currentPoint.getLatitudeE6() + destPoint.getLatitudeE6()) / 2 , (currentPoint.getLongitudeE6() + destPoint.getLongitudeE6()) / 2));
urlString.append( Double.toString((double)src.getLatitudeE6()/1.0E6 )); urlString.append(","); urlString.append( Double.toString((double)src.getLongitudeE6()/1.0E6 )); urlString.append("&daddr=");//to urlString.append( Double.toString((double)dest.getLatitudeE6()/1.0E6 )); urlString.append(","); urlString.append( Double.toString((double)dest.getLongitudeE6()/1.0E6 )); urlString.append("&ie=UTF8&0&om=0&output=kml"); Log.d("xxx","URL="+urlString.toString());
public void centerOverlays() { int minLat = 81 * MapStoresController.MAP_SCALE; int maxLat = -81 * MapStoresController.MAP_SCALE; int minLon = 181 * MapStoresController.MAP_SCALE; int maxLon = -181 * MapStoresController.MAP_SCALE; for (int i = 0; i < overlayItems.size(); i++) { Store s = overlayItems.getItem(i).getStore(); minLat = (int) ((minLat > (s.getLocation().getLatitude() * MapStoresController.MAP_SCALE)) ? s.getLocation().getLatitude() * MapStoresController.MAP_SCALE : minLat); maxLat = (int) ((maxLat < (s.getLocation().getLatitude() * MapStoresController.MAP_SCALE)) ? s.getLocation().getLatitude() * MapStoresController.MAP_SCALE : maxLat); minLon = (int) ((minLon > (s.getLocation().getLongitude() * MapStoresController.MAP_SCALE)) ? s.getLocation().getLongitude() * MapStoresController.MAP_SCALE : minLon); maxLon = (int) ((maxLon < (s.getLocation().getLongitude() * MapStoresController.MAP_SCALE)) ? .getLocation().getLongitude() * MapStoresController.MAP_SCALE : maxLon); } GeoPoint gp = controller.getUserLocation(); minLat = (minLat > gp.getLatitudeE6()) ? gp.getLatitudeE6() : minLat; maxLat = (maxLat < gp.getLatitudeE6()) ? gp.getLatitudeE6() : maxLat; minLon = (minLon > gp.getLongitudeE6()) ? gp.getLongitudeE6() : minLon; maxLon = (maxLon < gp.getLongitudeE6()) ? gp.getLongitudeE6() : maxLon; mapView.getController().zoomToSpan((maxLat - minLat), (maxLon - minLon)); mapView.getController().animateTo(new GeoPoint((maxLat + minLat) / 2, (maxLon + minLon) / 2)); }
GeoPoint newCurrent = new GeoPoint(59529200, 18071400); Location current = new Location("reverseGeocoded"); current.setLatitude(newCurrent.getLatitudeE6() / 1e6); current.setLongitude(newCurrent.getLongitudeE6() / 1e6); current.setAccuracy(3333); current.setBearing(333);
private void centerMap(GeoPoint center, int offX, int offY){ GeoPoint tl = mapView.getProjection().fromPixels(0, 0); GeoPoint br = mapView.getProjection().fromPixels(mapView.getWidth(), mapView.getHeight()); int newLon = offX * (br.getLongitudeE6() - tl.getLongitudeE6()) / mapView.getWidth() + center.getLongitudeE6(); int newLat = offY * (br.getLatitudeE6() - tl.getLatitudeE6()) / mapView.getHeight() + center.getLatitudeE6(); mapController.setCenter(new GeoPoint(newLat, newLon)); }
GeoPoint max = new GeoPoint(maxLatitude, maxLongitude); GeoPoint min = new GeoPoint(minLatitude, minLongitude); int maxLatMicro = max.getLatitudeE6(); int maxLonMicro = max.getLongitudeE6(); int minLatMicro = min.getLatitudeE6(); int minLonMicro = min.getLongitudeE6(); GeoPoint center = new GeoPoint((maxLatMicro+minLatMicro)/2,(maxLonMicro + minLonMicro)/2); controller.zoomToSpan(maxLatMicro - minLatMicro, maxLonMicro - minLonMicro); controller.animateTo(center);
int lat = (int) (location.getLatitude() * 1E6); int lng = (int) (location.getLongitude() * 1E6); GeoPoint point = new GeoPoint(lat, lng); tv_obj_long.setText("Latitude: "+ String.valueOf(point.getLatitudeE6() / 1E6)); tv_obj_lat.setText("Longitude: "+ String.valueOf(point.getLongitudeE6() / 1E6));
int minLat = Integer.MAX_VALUE; int minLong = Integer.MAX_VALUE; int maxLat = Integer.MIN_VALUE; int maxLong = Integer.MIN_VALUE; for (GeoPoint point : points) { minLat = Math.min(point.getLatitudeE6(), minLat); minLong = Math.min(point.getLongitudeE6(), minLong); maxLat = Math.max(point.getLatitudeE6(), maxLat); maxLong = Math.max(point.getLongitudeE6(), maxLong); } MapController controller = view.getController(); controller.zoomToSpan( Math.abs(minLat - maxLat), Math.abs(minLong - maxLong)); controller.animateTo(new GeoPoint((maxLat + minLat) / 2, (maxLong + minLong) / 2));
int minLat = Integer.MAX_VALUE; int maxLat = Integer.MIN_VALUE; int minLon = Integer.MAX_VALUE; int maxLon = Integer.MIN_VALUE; for (GeoPoint item : items) { int lat = item.getLatitudeE6(); int lon = item.getLongitudeE6(); maxLat = Math.max(lat, maxLat); minLat = Math.min(lat, minLat); maxLon = Math.max(lon, maxLon); minLon = Math.min(lon, minLon); } mapController.zoomToSpan(Math.abs(maxLat - minLat), Math.abs(maxLon - minLon)); mapController.animateTo(new GeoPoint( (maxLat + minLat)/2, (maxLon + minLon)/2 ));
private void AddPolygon() { int diff=1000; GeoPoint pt1=new GeoPoint(13.002798, 77.580000); GeoPoint pt2= new GeoPoint(pt1.getLatitudeE6()+diff, pt1.getLongitudeE6()); GeoPoint pt3= new GeoPoint(pt1.getLatitudeE6()+diff, pt1.getLongitudeE6()+diff); GeoPoint pt4= new GeoPoint(pt1.getLatitudeE6(), pt1.getLongitudeE6()+diff); GeoPoint pt5= new GeoPoint(pt1); PathOverlay myOverlay= new PathOverlay(Color.RED, this); myOverlay.getPaint().setStyle(Paint.Style.FILL); myOverlay.addPoint(pt1); myOverlay.addPoint(pt2); myOverlay.addPoint(pt3); myOverlay.addPoint(pt4); myOverlay.addPoint(pt5); map.getOverlays().add(myOverlay); }
int minLat = Integer.MAX_VALUE; int maxLat = Integer.MIN_VALUE; int minLon = Integer.MAX_VALUE; int maxLon = Integer.MIN_VALUE; for (GeoPoint item : items) { int lat = item.getLatitudeE6(); int lon = item.getLongitudeE6(); maxLat = Math.max(lat, maxLat); minLat = Math.min(lat, minLat); maxLon = Math.max(lon, maxLon); minLon = Math.min(lon, minLon); } double fitFactor = 1.5; mapController.zoomToSpan((int) (Math.abs(maxLat - minLat) * fitFactor), (int)(Math.abs(maxLon - minLon) * fitFactor)); mapController.animateTo(new GeoPoint( (maxLat + minLat)/2, (maxLon + minLon)/2 ));
double latiTude = 10.3929393; double longiTude = 150.93984884; Geocoder geocoder = new Geocoder(getBaseContext(), Locale.getDefault()); GeoPoint p= new GeoPoint((int) (latiTude * 1E6), (int) (longiTude * 1E6)); List<Address> address = geocoder.getFromLocation( p.getLatitudeE6() / 1E6, p.getLongitudeE6() / 1E6, 1); if (address.size() > 0) { String addressFroLatLong= ""; for (int i = 0; i < address.get(0).getMaxAddressLineIndex(); i++) { addressFroLatLong+= address.get(0).getAddressLine(i) + "\n"; } }
private class MyLocationListener implements LocationListener{ public void onLocationChanged(Location argLocation) { GeoPoint myGeoPoint = new GeoPoint( (int)(argLocation.getLatitude()*1000000), (int)(argLocation.getLongitude()*1000000)); GeoPoint newGeoPoint = new GeoPoint(myGeoPoint.getLatitudeE6(), myGeoPoint.getLongitudeE6()); Toast.makeText(GetApplicationContext(),"Lat:"+newGeoPoint.getLatitudeE6()/1000000,"Lang:"+newGeoPoint.getLongitudeE6()/1000000) }
double latiTude = 10.3929393; double longiTude = 150.93984884; Geocoder geocoder = new Geocoder(getBaseContext(), Locale.getDefault()); GeoPoint p= new GeoPoint((int) (latiTude * 1E6), (int) (longiTude * 1E6)); List<Address> address = geocoder.getFromLocation( p.getLatitudeE6() / 1E6, p.getLongitudeE6() / 1E6, 1); if (address.size() > 0) { String addressFroLatLong= ""; for (int i = 0; i < address.get(0).getMaxAddressLineIndex(); i++) { addressFroLatLong+= address.get(0).getAddressLine(i) + "\n"; } }
GeoPoint point = new GeoPoint(/* ... */, /* ... */); final SWayPoint wayPoint = new SWayPoint("", point.getLongitudeE6(), point.getLatitudeE6()); SError error = new SError(); final int returnCode = ApplicationAPI.StartNavigation(error, point, NavigationParams.NpMessageAvoidTollRoadsUnable, true, true, 0);
@Override public boolean onTap(GeoPoint p, MapView mapView) { Log.d("tap event ", "tap called"); mapOverlays = mapView.getOverlays(); drawable =getResources().getDrawable(R.drawable.marker); itemizedOverlay = new SitesOverlay(drawable); int lat=(int)p.getLatitudeE6(); int lng=(int)p.getLongitudeE6(); GeoPoint point = new GeoPoint(lat,lng); Log.d("tap event ", "tapcalled"+lat+""+lng); OverlayItem overlayitem = new OverlayItem(point, "", ""); items.add(overlayitem); populate(); Log.d("tap event ", "populated"); // mapOverlays.add(itemizedOverlay); return true; }
Location userLocation = new Location(); GeoPoint geoPoint = new GeoPoint(); float[] results = new float[3]; Location.distanceBetween(userLocation.getLatitude(), userLocation.getLongitude(), (geoPoint.getLatitudeE6()/1E6), (geoPoint.getLongitudeE6()/1E6), results); //result[0] = distance in m