use of com.mapbox.mapboxsdk.maps.MapboxMapOptions in project apps-android-commons by commons-app.
the class NearbyMapFragment method setupMapView.
private void setupMapView(Bundle savedInstanceState) {
MapboxMapOptions options = new MapboxMapOptions().styleUrl(Style.OUTDOORS).camera(new CameraPosition.Builder().target(new LatLng(curLatLng.getLatitude(), curLatLng.getLongitude())).zoom(11).build());
// create map
mapView = new MapView(getActivity(), options);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap mapboxMap) {
mapboxMap.addMarkers(baseMarkerOptions);
mapboxMap.setOnMarkerClickListener(new MapboxMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(@NonNull Marker marker) {
if (marker instanceof NearbyMarker) {
NearbyMarker nearbyMarker = (NearbyMarker) marker;
Place place = nearbyMarker.getNearbyBaseMarker().getPlace();
NearbyInfoDialog.showYourself(getActivity(), place);
}
return false;
}
});
addCurrentLocationMarker(mapboxMap);
}
});
if (PreferenceManager.getDefaultSharedPreferences(getActivity()).getBoolean("theme", true)) {
mapView.setStyleUrl(getResources().getString(R.string.map_theme_dark));
} else {
mapView.setStyleUrl(getResources().getString(R.string.map_theme_light));
}
}
use of com.mapbox.mapboxsdk.maps.MapboxMapOptions in project androidApp by InspectorIncognito.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG, "onCreate");
busButton = new BusToggleButton((ImageView) findViewById(R.id.floating_button_bus), null, false);
userMapLevel = findViewById(R.id.user_map_level);
userMapLevel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
openActivity(AccountActivity.class);
}
});
findViewById(R.id.floating_button_bus).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
busButtonClick();
}
});
// Sliding Panel Initialization
initializeSlidingPanel();
tittleView = getLayoutInflater().inflate(R.layout.activity_main_title_bar, null);
tittleText = tittleView.findViewById(R.id.activity_main_title_text);
tittleImage = tittleView.findViewById(R.id.activity_main_title_image);
// Connection Message
MessageLayout = findViewById(R.id.textOfflineBar);
ConnectionChange = ConnectionChangeReceiver.getBroadcastReceiverInstance();
// Create supportMapFragment
if (savedInstanceState == null) {
// Create fragment
final FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
Location location = PositionProvider.getInstance().getLastKnownLocation();
// Build mapboxMap
MapboxMapOptions options = new MapboxMapOptions();
options.styleUrl(Style.MAPBOX_STREETS);
options.camera(new CameraPosition.Builder().target(new LatLng(location.getLatitude(), location.getLongitude())).zoom(16).build());
// Create map fragment
mapFragment = VectorMapFragment.newInstance(options);
// Add map fragment to parent container
transaction.add(R.id.container, mapFragment, "com.mapbox.map");
transaction.commit();
} else {
mapFragment = (VectorMapFragment) getSupportFragmentManager().findFragmentByTag("com.mapbox.map");
}
Bundle extras = getIntent().getExtras();
if (extras != null) {
if (extras.containsKey(BUS_SERVICE_KEY) && extras.containsKey(BUS_TOKEN_KEY)) {
showEvaluationDialog(extras.getString(BUS_SERVICE_KEY), extras.getString(BUS_TOKEN_KEY));
}
}
onFoot();
}
Aggregations