Search in sources :

Example 1 with Position

use of com.mapbox.services.commons.models.Position 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());
}
Also used : Position(com.mapbox.services.commons.models.Position) CameraPosition(com.mapbox.mapboxsdk.camera.CameraPosition) Point(com.mapbox.services.commons.geojson.Point) ILatLng(com.mapbox.mapboxsdk.geometry.ILatLng) LatLng(com.mapbox.mapboxsdk.geometry.LatLng)

Example 2 with Position

use of com.mapbox.services.commons.models.Position in project mapbox-navigation-android by mapbox.

the class NavigationMapRoute method findPointOnLine.

private com.mapbox.geojson.Point findPointOnLine(com.mapbox.geojson.Point clickPoint, LineString lineString) {
    List<com.mapbox.geojson.Point> linePoints = new ArrayList<>();
    List<Position> positions = lineString.getCoordinates();
    for (Position pos : positions) {
        linePoints.add(com.mapbox.geojson.Point.fromLngLat(pos.getLongitude(), pos.getLatitude()));
    }
    com.mapbox.geojson.Feature feature = TurfMisc.nearestPointOnLine(clickPoint, linePoints);
    return (com.mapbox.geojson.Point) feature.geometry();
}
Also used : Position(com.mapbox.services.commons.models.Position) ArrayList(java.util.ArrayList) Point(com.mapbox.services.commons.geojson.Point)

Aggregations

Point (com.mapbox.services.commons.geojson.Point)2 Position (com.mapbox.services.commons.models.Position)2 CameraPosition (com.mapbox.mapboxsdk.camera.CameraPosition)1 ILatLng (com.mapbox.mapboxsdk.geometry.ILatLng)1 LatLng (com.mapbox.mapboxsdk.geometry.LatLng)1 ArrayList (java.util.ArrayList)1