float lat = -23.4456f; float lng = 45.44334f; GeoPoint gp = new GeoPoint((int)(lat * 1E6), (int)(lng * 1E6));
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 handleGeoBoundsAggregation(List<String> headers, List<List<String>> lines, GeoBounds geoBoundsAggregation) { String geoBoundAggName = geoBoundsAggregation.getName(); headers.add(geoBoundAggName+".topLeft.lon"); headers.add(geoBoundAggName+".topLeft.lat"); headers.add(geoBoundAggName+".bottomRight.lon"); headers.add(geoBoundAggName+".bottomRight.lat"); List<String> line = lines.get(this.currentLineIndex); line.add(String.valueOf(geoBoundsAggregation.topLeft().getLon())); line.add(String.valueOf(geoBoundsAggregation.topLeft().getLat())); line.add(String.valueOf(geoBoundsAggregation.bottomRight().getLon())); line.add(String.valueOf(geoBoundsAggregation.bottomRight().getLat())); lines.add(line); }
GeoPoint point = new GeoPoint((int)(latitude * 1e6), (int)(longitude * 1e6));
private void handleGeoBoundsAggregation(List<String> headers, List<List<Object>> lines, GeoBounds geoBoundsAggregation) { String geoBoundAggName = geoBoundsAggregation.getName(); headers.add(geoBoundAggName + ".topLeft.lon"); headers.add(geoBoundAggName + ".topLeft.lat"); headers.add(geoBoundAggName + ".bottomRight.lon"); headers.add(geoBoundAggName + ".bottomRight.lat"); List<Object> line = lines.get(this.currentLineIndex); line.add(String.valueOf(geoBoundsAggregation.topLeft().getLon())); line.add(String.valueOf(geoBoundsAggregation.topLeft().getLat())); line.add(String.valueOf(geoBoundsAggregation.bottomRight().getLon())); line.add(String.valueOf(geoBoundsAggregation.bottomRight().getLat())); lines.add(line); }
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); } }
float lat = -23.4456f; //in DecimalDegrees float lng = 45.44334f; //in DecimalDegrees GeoPoint gp = new GeoPoint((int)(lat * 1E6), (int)(lng * 1E6));
GeoPoint startGP = new GeoPoint((int) (Double.parseDouble(lngLat[1]) * 1E6), (int) (Double.parseDouble(lngLat[0]) * 1E6)); mMapView01.getOverlays().add(new RouteOverlay(startGP, startGP, 1)); GeoPoint gp1; if (lngLat.length >= 2 && gp1.getLatitudeE6() > 0 && gp1.getLongitudeE6() > 0 && gp2.getLatitudeE6() > 0 && gp2.getLongitudeE6() > 0) { gp2 = new GeoPoint((int) (Double.parseDouble(lngLat[1]) * 1E6), (int) (Double.parseDouble(lngLat[0]) * 1E6)); if (gp2.getLatitudeE6() != 22200000) { mMapView01.getOverlays().add(new RouteOverlay(gp1, gp2, 2, color)); Log.d(myapp.APP, "draw:" + gp1.getLatitudeE6() + "/" + gp1.getLongitudeE6() + " TO " + gp2.getLatitudeE6() + "/" + gp2.getLongitudeE6());
m_mapView.getController().setZoom(MAP_DEFAULT_ZOOM); m_mapView.getController().setCenter( new GeoPoint(MAP_DEFAULT_LATITUDE, MAP_DEFAULT_LONGITUDE)); m_mapView.setTileSource(TileSourceFactory.MAPNIK);
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();
lng += dlng; GeoPoint p = new GeoPoint((int) (((double) lat / 1E5) * 1E6), (int) (((double) lng / 1E5) * 1E6)); poly.add(p);
List<Address> addresses = geoCoder.getFromLocationName(txtsearch.getText().toString(),5); if(addresses.size() > 0) { p = new GeoPoint( (int) (addresses.get(0).getLatitude() * 1E6), (int) (addresses.get(0).getLongitude() * 1E6)); controller.animateTo(p); controller.setZoom(12); MapOverlay mapOverlay = new MapOverlay(); List<Overlay> listOfOverlays = map.getOverlays(); listOfOverlays.clear(); listOfOverlays.add(mapOverlay); map.invalidate(); txtsearch.setText(""); } else { AlertDialog.Builder adb = new AlertDialog.Builder(GoogleMap.this); adb.setTitle("Google Map"); adb.setMessage("Please Provide the Proper Place"); adb.setPositiveButton("Close",null); adb.show(); }
lng += dlng; GeoPoint p = new GeoPoint((int) (((double) lat / 1E5) * 1E6), (int) (((double) lng / 1E5) * 1E6)); poly.add(p);
out.add(new GeoPoint((lat*10),(lng*10)));
out[cnt++] = new GeoPoint((lat*10),(lng*10));
private ImageView mCurrentPointer; @Override public void onLocationChanged(Location l) { int latitude = (int) (l.getLatitude() * 1e6); int longitude = (int) (l.getLongitude() * 1e6); // Prepare new LayoutParams object that centers on our new latitude/longitude MapView.LayoutParams lp = new MapView.LayoutParams(MapView.LayoutParams.WRAP_CONTENT, MapView.LayoutParams.WRAP_CONTENT, new GeoPoint(latitude, longitude), MapView.LayoutParams.CENTER); if (mCurrentPointer == null) { // If "current location" pin is null, we haven't added it // to MapView yet. So instantiate it and add it to MapView: mCurrentPointer = new ImageView(this); mCurrentPointer.setImageResource(R.drawable.ic_maps_indicator_current_position); mMapView.addView(mCurrentPointer, lp); } else { // If it's already added, just update its location mCurrentPointer.setLayoutParams(lp); } }
double glon = Double.parseDouble(glons); double glat = Double.parseDouble(glats); GeoPoint g = new GeoPoint(glon, glat); String korisni_linii = result.get(3);
public GeoPoint getLocationFromAddress(String strAddress){ Geocoder coder = new Geocoder(this); List<Address> address; GeoPoint p1 = null; try { address = coder.getFromLocationName(strAddress,5); if (address==null) { return null; } Address location=address.get(0); location.getLatitude(); location.getLongitude(); p1 = new GeoPoint((double) (location.getLatitude() * 1E6), (double) (location.getLongitude() * 1E6)); return p1; } }