Search in sources :

Example 1 with MapPosition

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;
}
Also used : MapPosition(org.oscim.core.MapPosition)

Example 2 with 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);
}
Also used : MapPosition(org.oscim.core.MapPosition) GeoPoint(org.oscim.core.GeoPoint)

Example 3 with MapPosition

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();
        }
    });
}
Also used : Status(com.google.android.gms.common.api.Status) PlaceImpl(com.google.android.gms.location.places.internal.PlaceImpl) LatLngBounds(com.google.android.gms.maps.model.LatLngBounds) GmsMapsTypeHelper.fromLatLngBounds(org.microg.gms.maps.GmsMapsTypeHelper.fromLatLngBounds) Intent(android.content.Intent) TextView(android.widget.TextView) SearchView(android.support.v7.widget.SearchView) View(android.view.View) TextView(android.widget.TextView) BackendMapView(org.microg.gms.maps.BackendMapView) MapPosition(org.oscim.core.MapPosition) Toolbar(android.support.v7.widget.Toolbar)

Example 4 with MapPosition

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));
    }
}
Also used : LocationManager(android.location.LocationManager) MapPosition(org.oscim.core.MapPosition) Location(android.location.Location)

Aggregations

MapPosition (org.oscim.core.MapPosition)4 Intent (android.content.Intent)1 Location (android.location.Location)1 LocationManager (android.location.LocationManager)1 SearchView (android.support.v7.widget.SearchView)1 Toolbar (android.support.v7.widget.Toolbar)1 View (android.view.View)1 TextView (android.widget.TextView)1 Status (com.google.android.gms.common.api.Status)1 PlaceImpl (com.google.android.gms.location.places.internal.PlaceImpl)1 LatLngBounds (com.google.android.gms.maps.model.LatLngBounds)1 BackendMapView (org.microg.gms.maps.BackendMapView)1 GmsMapsTypeHelper.fromLatLngBounds (org.microg.gms.maps.GmsMapsTypeHelper.fromLatLngBounds)1 GeoPoint (org.oscim.core.GeoPoint)1