Search in sources :

Example 1 with MapboxMapOptions

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));
    }
}
Also used : MapboxMapOptions(com.mapbox.mapboxsdk.maps.MapboxMapOptions) GsonBuilder(com.google.gson.GsonBuilder) NonNull(android.support.annotation.NonNull) MapView(com.mapbox.mapboxsdk.maps.MapView) OnMapReadyCallback(com.mapbox.mapboxsdk.maps.OnMapReadyCallback) LatLng(com.mapbox.mapboxsdk.geometry.LatLng) Marker(com.mapbox.mapboxsdk.annotations.Marker) MapboxMap(com.mapbox.mapboxsdk.maps.MapboxMap)

Example 2 with MapboxMapOptions

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();
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) AccountActivity(cl.smartcities.isci.transportinspector.gamification.ui.AccountActivity) Bundle(android.os.Bundle) MapboxMapOptions(com.mapbox.mapboxsdk.maps.MapboxMapOptions) BusToggleButton(cl.smartcities.isci.transportinspector.map.buttons.BusToggleButton) ImageView(android.widget.ImageView) LatLng(com.mapbox.mapboxsdk.geometry.LatLng) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) Location(android.location.Location)

Aggregations

LatLng (com.mapbox.mapboxsdk.geometry.LatLng)2 MapboxMapOptions (com.mapbox.mapboxsdk.maps.MapboxMapOptions)2 Location (android.location.Location)1 Bundle (android.os.Bundle)1 NonNull (android.support.annotation.NonNull)1 FragmentTransaction (android.support.v4.app.FragmentTransaction)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 AccountActivity (cl.smartcities.isci.transportinspector.gamification.ui.AccountActivity)1 BusToggleButton (cl.smartcities.isci.transportinspector.map.buttons.BusToggleButton)1 GsonBuilder (com.google.gson.GsonBuilder)1 Marker (com.mapbox.mapboxsdk.annotations.Marker)1 MapView (com.mapbox.mapboxsdk.maps.MapView)1 MapboxMap (com.mapbox.mapboxsdk.maps.MapboxMap)1 OnMapReadyCallback (com.mapbox.mapboxsdk.maps.OnMapReadyCallback)1