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);
}
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()));
}
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();
}
}
}
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);
}
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);
}
}
Aggregations