use of org.oscim.core.MapPosition in project android_packages_apps_GmsCore by microg.
the class GmsMapsTypeHelper method fromCameraPosition.
public static MapPosition fromCameraPosition(CameraPosition cameraPosition) {
MapPosition mapPosition = new MapPosition(cameraPosition.target.latitude, cameraPosition.target.longitude, fromZoom(cameraPosition.zoom));
mapPosition.setTilt(cameraPosition.tilt);
mapPosition.setBearing(fromBearing(cameraPosition.bearing));
return mapPosition;
}
use of org.oscim.core.MapPosition in project PocketMaps by junjunguo.
the class MapActions method doZoom.
void doZoom(MapView mapView, boolean doZoomIn) {
MapPosition mvp = mapView.map().getMapPosition();
int i = mvp.getZoomLevel();
log("Zoom from " + mvp.getZoomLevel() + " scale=" + mvp.getScale());
if (doZoomIn) {
mvp.setZoomLevel(++i);
mvp.setScale(mvp.getScale() * 1.1);
/* roundoff err */
} else {
mvp.setZoomLevel(--i);
}
log("Zoom to " + mvp.getZoomLevel());
mapView.map().animator().animateTo(300, mvp);
}
use of org.oscim.core.MapPosition in project android_packages_apps_GmsCore by microg.
the class PlacePickerActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
resultIntent = new Intent();
place = new PlaceImpl();
setContentView(R.layout.pick_place);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
if (getIntent().hasExtra(EXTRA_PRIMARY_COLOR)) {
toolbar.setBackgroundColor(getIntent().getIntExtra(EXTRA_PRIMARY_COLOR, 0));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
getWindow().setStatusBarColor(getIntent().getIntExtra(EXTRA_PRIMARY_COLOR_DARK, 0));
((TextView) findViewById(R.id.place_picker_title)).setTextColor(getIntent().getIntExtra(EXTRA_PRIMARY_COLOR_DARK, 0));
}
mapView = (BackendMapView) findViewById(R.id.map);
mapView.map().getEventLayer().enableRotation(false);
mapView.map().getEventLayer().enableTilt(false);
mapView.map().events.bind(this);
LatLngBounds latLngBounds = getIntent().getParcelableExtra(LocationConstants.EXTRA_BOUNDS);
if (latLngBounds != null) {
place.viewport = latLngBounds;
MapPosition mp = new MapPosition();
mp.setByBoundingBox(fromLatLngBounds(latLngBounds), mapView.map().getWidth(), mapView.map().getHeight());
mapView.map().getMapPosition(mp);
} else {
if (ActivityCompat.checkSelfPermission(PlacePickerActivity.this, ACCESS_FINE_LOCATION) != PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(PlacePickerActivity.this, new String[] { ACCESS_COARSE_LOCATION, ACCESS_FINE_LOCATION }, 0);
} else {
updateMapFromLocationManager();
}
}
findViewById(R.id.place_picker_select).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
resultIntent.putExtra(LocationConstants.EXTRA_STATUS, SafeParcelUtil.asByteArray(new Status(CommonStatusCodes.SUCCESS)));
resultIntent.putExtra(LocationConstants.EXTRA_PLACE, SafeParcelUtil.asByteArray(place));
resultIntent.putExtra(LocationConstants.EXTRA_FINAL_BOUNDS, SafeParcelUtil.asByteArray(place.viewport));
setResult(RESULT_OK, resultIntent);
finish();
}
});
}
use of org.oscim.core.MapPosition in project android_packages_apps_GmsCore by microg.
the class PlacePickerActivity method updateMapFromLocationManager.
@SuppressWarnings("MissingPermission")
private void updateMapFromLocationManager() {
LocationManager lm = (LocationManager) getSystemService(LOCATION_SERVICE);
Location last = null;
for (String provider : lm.getAllProviders()) {
if (lm.isProviderEnabled(provider)) {
Location t = lm.getLastKnownLocation(provider);
if (t != null && (last == null || t.getTime() > last.getTime())) {
last = t;
}
}
}
Log.d(TAG, "Set location to " + last);
if (last != null) {
mapView.map().setMapPosition(new MapPosition(last.getLatitude(), last.getLongitude(), 4096));
}
}
Aggregations