Search in sources :

Example 36 with LatLng

use of com.mapbox.mapboxsdk.geometry.LatLng in project osm-contributor by jawg.

the class Way method add.

public void add(PoiNodeRef poiNodeRef) {
    polylineOptions.add(new LatLng(poiNodeRef.getLatitude(), poiNodeRef.getLongitude()));
    poiNodeRefs.add(poiNodeRef);
}
Also used : LatLng(com.mapbox.mapboxsdk.geometry.LatLng)

Example 37 with LatLng

use of com.mapbox.mapboxsdk.geometry.LatLng in project osm-contributor by jawg.

the class MapFragment method instantiateMapBox.

private void instantiateMapBox(Bundle savedInstanceState) {
    // LocationView settings
    mapboxMap.getMyLocationViewSettings().setAccuracyAlpha(0);
    mapboxMap.getMyLocationViewSettings().setForegroundTintColor(ContextCompat.getColor(getActivity(), R.color.colorPrimaryTransparent));
    // Set the map center and zoom to the saved values or use the default values
    getUserLocation();
    CameraPosition.Builder cameraBuilder = new CameraPosition.Builder();
    if (savedInstanceState == null) {
        double lat = sharedPreferences.getFloat("latitude", 0);
        double lon = sharedPreferences.getFloat("longitude", 0);
        if (lat != 0 && lon != 0) {
            cameraBuilder.target(new LatLng(lat, lon)).zoom(11);
        }
    } else {
        cameraBuilder.target((LatLng) savedInstanceState.getParcelable(LOCATION)).zoom(savedInstanceState.getFloat(ZOOM_LEVEL));
    }
    mapboxMap.setCameraPosition(cameraBuilder.build());
    presenter.setForceRefreshPoi();
    presenter.setForceRefreshNotes();
    presenter.loadPoisIfNeeded();
    eventBus.post(new PleaseInitializeNoteDrawerEvent(displayOpenNotes, displayClosedNotes));
    if (poiTypePickerAdapter != null) {
        poiTypePickerAdapter.setExpertMode(sharedPreferences.getBoolean(getString(R.string.shared_prefs_expert_mode), false));
    }
    mapboxListener.listen(mapboxMap, mapView);
    mapboxMap.getMarkerViewManager().addMarkerViewAdapter(new LocationMarkerViewAdapter(getActivity().getApplicationContext()));
}
Also used : CameraPosition(com.mapbox.mapboxsdk.camera.CameraPosition) PleaseInitializeNoteDrawerEvent(io.jawg.osmcontributor.ui.events.map.PleaseInitializeNoteDrawerEvent) LatLng(com.mapbox.mapboxsdk.geometry.LatLng) LocationMarkerViewAdapter(io.jawg.osmcontributor.ui.utils.views.LocationMarkerViewAdapter)

Example 38 with LatLng

use of com.mapbox.mapboxsdk.geometry.LatLng in project osm-contributor by jawg.

the class MapFragment method onResume.

@Override
public void onResume() {
    super.onResume();
    mapView.onResume();
    if (mapboxMap != null) {
        switchMode(MapMode.DEFAULT);
        presenter.setForceRefreshPoi();
        presenter.setForceRefreshNotes();
        presenter.loadPoisIfNeeded();
        nextTuto(2);
        double lat = sharedPreferences.getFloat("latitude", 0);
        double lon = sharedPreferences.getFloat("longitude", 0);
        if (lat != 0 && lon != 0) {
            CameraPosition cameraPosition = new CameraPosition.Builder().target(new LatLng(lat, lon)).zoom(mapboxMap.getCameraPosition().zoom).build();
            mapboxMap.setCameraPosition(cameraPosition);
        } else {
            getUserLocation();
        }
    }
}
Also used : CameraPosition(com.mapbox.mapboxsdk.camera.CameraPosition) LatLng(com.mapbox.mapboxsdk.geometry.LatLng)

Example 39 with LatLng

use of com.mapbox.mapboxsdk.geometry.LatLng in project osm-contributor by jawg.

the class MapFragment method buildEditionPolygon.

private void buildEditionPolygon() {
    // Current selected poiNodeRef
    PoiNodeRef currentPoiNodeRef = wayMarkerSelected.getPoiNodeRef();
    // Polyline related to this poiNodeRef
    PolylineOptions currentPolyline = polylinesWays.get(currentPoiNodeRef.getId());
    // Item of the poiNodeRef in the polilyne
    int indexOfPoiNodeRef = currentPolyline.getPoints().indexOf(new LatLng(currentPoiNodeRef.getLatitude(), currentPoiNodeRef.getLongitude()));
    LatLng previousPoint = currentPolyline.getPoints().get(indexOfPoiNodeRef == 0 ? indexOfPoiNodeRef + 1 : indexOfPoiNodeRef - 1);
    LatLng nextPoint = currentPolyline.getPoints().get(indexOfPoiNodeRef == currentPolyline.getPoints().size() - 1 ? indexOfPoiNodeRef - 1 : indexOfPoiNodeRef + 1);
    editionPolyline = new PolylineOptions().add(previousPoint, currentPolyline.getPoints().get(indexOfPoiNodeRef), nextPoint).alpha(0.4f).width(1.8f).color(Color.parseColor("#F57C00"));
    mapboxMap.addPolyline(editionPolyline);
}
Also used : LatLng(com.mapbox.mapboxsdk.geometry.LatLng) PoiNodeRef(io.jawg.osmcontributor.model.entities.PoiNodeRef) PolylineOptions(com.mapbox.mapboxsdk.annotations.PolylineOptions)

Example 40 with LatLng

use of com.mapbox.mapboxsdk.geometry.LatLng in project osm-contributor by jawg.

the class MapFragment method createPoi.

private void createPoi() {
    LatLng pos = mapboxMap.getCameraPosition().target;
    boolean needTagEdition = false;
    for (PoiTypeTag poiTypeTag : poiTypeSelected.getTags()) {
        if (StringUtils.isEmpty(poiTypeTag.getValue())) {
            needTagEdition = true;
            break;
        }
    }
    if (needTagEdition) {
        Intent intent = new Intent(getActivity(), EditPoiActivity.class);
        intent.putExtra(EditPoiActivity.CREATION_MODE, true);
        intent.putExtra(EditPoiActivity.POI_LAT, pos.getLatitude());
        intent.putExtra(EditPoiActivity.POI_LNG, pos.getLongitude());
        intent.putExtra(EditPoiActivity.POI_LEVEL, isVectorial ? currentLevel : 0d);
        intent.putExtra(EditPoiActivity.POI_TYPE, poiTypeSelected.getId());
        switchMode(MapMode.DEFAULT);
        getActivity().startActivityForResult(intent, EditPoiActivity.EDIT_POI_ACTIVITY_CODE);
    } else {
        eventBus.post(new PleaseCreateNoTagPoiEvent(poiTypeSelected, pos, isVectorial ? currentLevel : 0d));
        switchMode(MapMode.DEFAULT);
    }
}
Also used : Intent(android.content.Intent) LatLng(com.mapbox.mapboxsdk.geometry.LatLng) PoiTypeTag(io.jawg.osmcontributor.model.entities.PoiTypeTag) PleaseCreateNoTagPoiEvent(io.jawg.osmcontributor.ui.events.map.PleaseCreateNoTagPoiEvent)

Aggregations

LatLng (com.mapbox.mapboxsdk.geometry.LatLng)56 CameraPosition (com.mapbox.mapboxsdk.camera.CameraPosition)12 ArrayList (java.util.ArrayList)10 Point (com.mapbox.geojson.Point)7 LatLngBounds (com.mapbox.mapboxsdk.geometry.LatLngBounds)6 MapboxMap (com.mapbox.mapboxsdk.maps.MapboxMap)6 NonNull (android.support.annotation.NonNull)5 PointF (android.graphics.PointF)4 OnMapReadyCallback (com.mapbox.mapboxsdk.maps.OnMapReadyCallback)4 ValueAnimator (android.animation.ValueAnimator)3 MultiLocationEngine (cl.smartcities.isci.transportinspector.map.engine.MultiLocationEngine)3 MultiLayerOnMapClickListener (cl.smartcities.isci.transportinspector.map.utils.MultiLayerOnMapClickListener)3 MarkerOptions (com.mapbox.mapboxsdk.annotations.MarkerOptions)3 Poi (io.jawg.osmcontributor.model.entities.Poi)3 Subscribe (org.greenrobot.eventbus.Subscribe)3 Intent (android.content.Intent)2 Location (android.location.Location)2 View (android.view.View)2 RouteHelper (cl.smartcities.isci.transportinspector.database.RouteHelper)2 BusClickHandler (cl.smartcities.isci.transportinspector.map.model.bus.BusClickHandler)2