use of com.mapbox.mapboxsdk.geometry.LatLng in project osm-contributor by jawg.
the class MapFragment method confirmPosition.
private void confirmPosition() {
LatLng newPoiPosition;
LatLng pos;
switch(mapMode) {
case POI_CREATION:
if (getZoomLevel() < zoomVectorial) {
changeMapZoomSmooth(15d);
}
createPoi();
break;
case NOTE_CREATION:
pos = mapboxMap.getCameraPosition().target;
NoteCommentDialogFragment dialog = NoteCommentDialogFragment.newInstance(pos.getLatitude(), pos.getLongitude());
dialog.show(getActivity().getFragmentManager(), "dialog");
break;
case POI_POSITION_EDITION:
Poi poi = (Poi) markerSelected.getRelatedObject();
newPoiPosition = mapboxMap.getCameraPosition().target;
eventBus.post(new PleaseApplyPoiPositionChange(newPoiPosition, poi.getId()));
markerSelected.setPosition(newPoiPosition);
markerSelected.setIcon(IconFactory.getInstance(getActivity()).fromBitmap(bitmapHandler.getMarkerBitmap(poi.getType(), Poi.computeState(false, false, true))));
poi.setUpdated(true);
mapboxMap.updateMarker(markerSelected);
switchMode(MapMode.DETAIL_POI);
break;
case NODE_REF_POSITION_EDITION:
PoiNodeRef poiNodeRef = wayMarkerSelected.getPoiNodeRef();
newPoiPosition = mapboxMap.getCameraPosition().target;
eventBus.post(new PleaseApplyNodeRefPositionChange(newPoiPosition, poiNodeRef.getId()));
wayMarkerSelected.setPosition(newPoiPosition);
wayMarkerSelected.setIcon(IconFactory.getInstance(getActivity()).fromBitmap(bitmapHandler.getNodeRefBitmap(PoiNodeRef.State.SELECTED)));
removePolyline(editionPolyline);
switchMode(MapMode.WAY_EDITION);
break;
case DETAIL_POI:
getActivity().finish();
break;
default:
break;
}
}
use of com.mapbox.mapboxsdk.geometry.LatLng in project androidApp by InspectorIncognito.
the class BusStopPlugin method getOnMapClickListener.
public MultiLayerOnMapClickListener getOnMapClickListener() {
return new MultiLayerOnMapClickListener() {
@Override
public boolean onMapClick(@NonNull LatLng point) {
PointF screenPoint = mapboxMap.getProjection().toScreenLocation(point);
final List<Feature> allFeatures = mapboxMap.queryRenderedFeatures(screenPoint);
Collections.reverse(allFeatures);
for (Feature feature : allFeatures) {
if (feature.hasProperty(BusStopMarker.PROPERTY_TYPE) && feature.getStringProperty(BusStopMarker.PROPERTY_TYPE).equals(BusStopMarker.PROPERTY_TYPE_BUS_STOP)) {
BusStopClickHandler handler = new BusStopClickHandler(getContext().getResources(), periodicRequestHandler, BusStopPlugin.this);
// BUS STOP FEATURE CLICK
final List<Feature> busStopsInfoWindows = mapboxMap.queryRenderedFeatures(screenPoint, BUS_STOP_INFO_WINDOW_LAYER_ID_MAX, BUS_STOP_INFO_WINDOW_LAYER_ID_MIN);
if (!busStopsInfoWindows.isEmpty()) {
// INFO WINDOW CLICK
Feature busStopInfoWindowFeature = getFeatureByStringProperty(busStopsInfoWindows.get(0), busStopFeatures, BusStopMarker.PROPERTY_ID);
PointF symbolScreenPoint = mapboxMap.getProjection().toScreenLocation(MapboxUtil.convertToLatLng(busStopInfoWindowFeature));
if (handler.handleInfoWindowClick(busStopInfoWindowFeature, screenPoint, symbolScreenPoint, viewMap)) {
if (selectedBus != null) {
deselectSelectedBusFeature();
centerCameraInSelection(busStopInfoWindowFeature);
}
refreshBusStopSource();
}
return true;
} else {
// MARKER CLICK
Log.d(BusStopPlugin.class.getSimpleName(), "MARKER CLICK");
busStopFeatureClick(feature, handler);
return true;
}
} else if (feature.hasProperty(BusMarker.PROPERTY_TYPE) && feature.getStringProperty(BusMarker.PROPERTY_TYPE).equals(BusMarker.PROPERTY_TYPE_BUS)) {
// BUS FEATURE CLICK
final List<Feature> infoWindowFeature = mapboxMap.queryRenderedFeatures(screenPoint, BUS_INFO_WINDOW_LAYER_ID_MAX);
if (!infoWindowFeature.isEmpty()) {
BusClickHandler handler = new BusClickHandler(getContext().getResources(), periodicRequestHandler, listener);
Feature selectedFeature = getFeatureByStringProperty(infoWindowFeature.get(0), busesFeatures, Marker.PROPERTY_ID);
PointF symbolScreenPoint = mapboxMap.getProjection().toScreenLocation(MapboxUtil.convertToLatLng(feature));
assert (selectedFeature) != null;
if (handler.handleInfoWindowClick(((BusMarker) selectedFeature).getBus(), screenPoint, symbolScreenPoint, viewMap, false)) {
return true;
}
}
busFeatureClick(feature);
return true;
}
}
// we didn't find a click event on any layer
if (busStopServiceCall != null && !busStopServiceCall.isCanceled()) {
Log.d(BusStopPlugin.class.getSimpleName(), "busStopServiceCall.cancel()");
busStopServiceCall.cancel();
} else if (selectedBusStop != null) {
deselectSelectedBusStop();
}
return false;
}
};
}
use of com.mapbox.mapboxsdk.geometry.LatLng in project androidApp by InspectorIncognito.
the class BusStopPlugin method busFeatureClick.
private void busFeatureClick(Feature selectedBusFeature) {
Log.d("BusStopPlugin", "busFeatureClick");
Feature busFeature = getFeatureByStringProperty(selectedBusFeature, busesFeatures, BusMarker.PROPERTY_ID);
if (busFeature == null) {
return;
}
if (selectedBus != null) {
if (busFeature.getId().equals(selectedBus.getId())) {
boolean maximized = selectedBus.getBooleanProperty(BusMarker.PROPERTY_MAXIMIZED);
selectedBus.addBooleanProperty(BusMarker.PROPERTY_MAXIMIZED, !maximized);
refreshBusSource();
return;
} else {
deselectSelectedBusFeature();
}
}
busFeature.addBooleanProperty(BusMarker.PROPERTY_MAXIMIZED, true);
selectedBus = busFeature;
selectedBusStop.addBooleanProperty(BusStopMarker.PROPERTY_MAXIMIZED, false);
refreshBusSource();
refreshBusStopSource();
RouteHelper helper = new RouteHelper(getContext());
ServerSentBus bus = ((BusMarker) busFeature).getBus();
ArrayList<LatLng> points = helper.getRoute(bus.getService(), bus.getDirection());
busPolyline = addBusRoutePolyline(points, Constants.BUS_COLOR.get(bus.getColorArrayIndex()));
animateCameraToSelection(busFeature);
}
use of com.mapbox.mapboxsdk.geometry.LatLng in project androidApp by InspectorIncognito.
the class UserPlugin method locationChangeAnimate.
/*
* Animators
*/
/**
* Handles the animation from currentSourcePoint to the new user location point.
*/
private void locationChangeAnimate(@NonNull final GeoJsonSource locationGeoJsonSource, @NonNull Point currentSourcePoint, @NonNull Point newPoint) {
if (locationChangeAnimator != null) {
locationChangeAnimator.end();
}
locationChangeAnimator = ValueAnimator.ofObject(new PointEvaluator(), currentSourcePoint, newPoint);
locationChangeAnimator.setDuration(linearAnimation ? getLocationUpdateDuration() : LocationLayerConstants.LOCATION_UPDATE_DELAY_MS);
if (linearAnimation) {
locationChangeAnimator.setInterpolator(new LinearInterpolator());
} else {
locationChangeAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
}
locationChangeAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
previousPoint = (Point) animation.getAnimatedValue();
userLocationFeature.setGeometry(previousPoint);
locationGeoJsonSource.setGeoJson(userLocationFeature);
if (tracking) {
mapboxMap.animateCamera(CameraUpdateFactory.newLatLng(new LatLng(previousPoint.getCoordinates().getLatitude(), previousPoint.getCoordinates().getLongitude())));
}
}
});
locationChangeAnimator.start();
}
use of com.mapbox.mapboxsdk.geometry.LatLng in project androidApp by InspectorIncognito.
the class MapboxUtil method convertToLatLng.
public static LatLng convertToLatLng(Feature feature) {
Point symbolPoint = (Point) feature.getGeometry();
Position position = symbolPoint.getCoordinates();
return new LatLng(position.getLatitude(), position.getLongitude());
}
Aggregations