Search in sources :

Example 6 with MapMarker

use of com.here.android.mpa.mapping.MapMarker in project here-android-sdk-examples by heremaps.

the class MapFragmentView method startNavigationSimulation.

private void startNavigationSimulation(GeoCoordinate startPosition) {
    changeState(State.DEFAULT);
    if (m_route != null) {
        m_map.setCenter(m_routePlan.getWaypoint(0).getNavigablePosition(), Map.Animation.NONE);
        m_navigationManager = NavigationManager.getInstance();
        m_navigationManager.setMapUpdateMode(NavigationManager.MapUpdateMode.ROADVIEW_NOZOOM);
        PointF transformCenter = new PointF((float) startPosition.getLatitude(), (float) startPosition.getLongitude());
        m_map.setTransformCenter(transformCenter);
        m_map.setZoomLevel(m_map.getMaxZoomLevel());
        m_map.setTilt(60);
        MapMarker mapMarker = new MapMarker();
        mapMarker.setVisible(true);
        mapMarker.setCoordinate(m_map.getCenter());
        m_map.addMapObject(mapMarker);
        m_mapFragment.getPositionIndicator().setVisible(true);
        m_map.setMapScheme(Map.Scheme.CARNAV_DAY);
        m_navigationManager.setMap(m_map);
        changeState(State.DEFAULT);
        m_isRouteSimulationFinished = false;
        NavigationManager.Error simulationError = m_navigationManager.simulate(m_route, CAR_SPEED);
        if (simulationError != NavigationManager.Error.NONE) {
            Toast.makeText(m_activity, m_activity.getText(R.string.simulation_error) + simulationError.toString(), Toast.LENGTH_LONG).show();
        } else {
            changeState(State.STOP_NAVIGATION);
        }
    } else {
        Toast.makeText(m_activity, m_activity.getText(R.string.error_null_route), Toast.LENGTH_LONG).show();
    }
}
Also used : NavigationManager(com.here.android.mpa.guidance.NavigationManager) MapMarker(com.here.android.mpa.mapping.MapMarker) PointF(android.graphics.PointF)

Example 7 with MapMarker

use of com.here.android.mpa.mapping.MapMarker in project here-android-sdk-examples by heremaps.

the class MapFragmentView method addMarkerAtPlace.

// Place markers handling helpers
private void addMarkerAtPlace(PlaceLink placeLink) {
    Image img = new Image();
    try {
        img.setImageResource(R.drawable.marker);
    } catch (IOException e) {
        e.printStackTrace();
    }
    MapMarker mapMarker = new MapMarker();
    mapMarker.setIcon(img);
    mapMarker.setCoordinate(new GeoCoordinate(placeLink.getPosition()));
    Map map = m_mapFragment.getMap();
    map.addMapObject(mapMarker);
    m_mapObjectList.add(mapMarker);
}
Also used : MapMarker(com.here.android.mpa.mapping.MapMarker) GeoCoordinate(com.here.android.mpa.common.GeoCoordinate) IOException(java.io.IOException) Image(com.here.android.mpa.common.Image) Map(com.here.android.mpa.mapping.Map)

Example 8 with MapMarker

use of com.here.android.mpa.mapping.MapMarker in project here-android-sdk-examples by heremaps.

the class MapFragmentView method downloadLayer.

/**
 * Download all layer data to remote storage
 */
private void downloadLayer() {
    clearMap();
    // get instance of the data manager
    final CLE2DataManager dataManager = CLE2DataManager.getInstance();
    final String layerName = m_layerEdit.getText().toString();
    // create download layer task
    CLE2Task<CLE2OperationResult> task = dataManager.newDownloadLayerTask(layerName);
    // start downloading
    task.start(new CLE2Task.Callback<CLE2OperationResult>() {

        @Override
        public void onTaskFinished(@Nullable CLE2OperationResult cle2OperationResult, @NonNull CLE2Request.CLE2Error cle2Error) {
            if (cle2Error.getErrorCode() != CLE2Request.CLE2Error.CLE2ErrorCode.NONE || cle2OperationResult == null) {
                Toast.makeText(m_activity, "Error : " + cle2Error.getErrorMessage(), Toast.LENGTH_LONG).show();
                return;
            }
            Toast.makeText(m_activity, "Operation completed successfully.\n" + "Number of downloaded objects is " + cle2OperationResult.getAffectedItemCount(), Toast.LENGTH_SHORT).show();
            // now fetch geometry from local storage
            CLE2Task<List<CLE2Geometry>> fetchTask = dataManager.newFetchLocalLayersTask(Collections.singletonList(layerName));
            fetchTask.start(new CLE2Task.Callback<List<CLE2Geometry>>() {

                @Override
                public void onTaskFinished(@Nullable List<CLE2Geometry> cle2Geometries, @NonNull CLE2Request.CLE2Error cle2Error) {
                    if (cle2Error.getErrorCode() != CLE2Request.CLE2Error.CLE2ErrorCode.NONE || cle2Geometries == null) {
                        Toast.makeText(m_activity, "Error : " + cle2Error.getErrorMessage(), Toast.LENGTH_LONG).show();
                        return;
                    }
                    for (CLE2Geometry geometry : cle2Geometries) {
                        CLE2PointGeometry pointGeometry = (CLE2PointGeometry) geometry;
                        m_geometryList.add(pointGeometry);
                        MapMarker mapMarker = new MapMarker(pointGeometry.getPoint());
                        m_map.addMapObject(mapMarker);
                    }
                }
            });
        }
    });
}
Also used : MapMarker(com.here.android.mpa.mapping.MapMarker) CLE2Request(com.here.android.mpa.customlocation2.CLE2Request) CLE2Geometry(com.here.android.mpa.customlocation2.CLE2Geometry) CLE2OperationResult(com.here.android.mpa.customlocation2.CLE2OperationResult) CLE2Task(com.here.android.mpa.customlocation2.CLE2Task) NonNull(androidx.annotation.NonNull) ArrayList(java.util.ArrayList) List(java.util.List) CLE2DataManager(com.here.android.mpa.customlocation2.CLE2DataManager) CLE2PointGeometry(com.here.android.mpa.customlocation2.CLE2PointGeometry) Nullable(androidx.annotation.Nullable)

Example 9 with MapMarker

use of com.here.android.mpa.mapping.MapMarker in project here-android-sdk-examples by heremaps.

the class MapFragmentView method addFakeRoute.

// Sends the fake route into the server and displays on the map.
// Note, layer uploading functionality is not part of the Mobile SDK 3.X, this was added
// added for demo purposes.
// Refer to the  official fleet telematics documentation to properly implement uploading
// layer on the server.
private void addFakeRoute() {
    m_fakeRoute = new GeoCoordinate[] { new GeoCoordinate(52.51517456956208, 13.35019220598042), new GeoCoordinate(52.51693326048553, 13.350012330338359), new GeoCoordinate(52.51796909607947, 13.350633010268211), new GeoCoordinate(52.51875473186374, 13.351499531418085), new GeoCoordinate(52.519415309652686, 13.350413320586085), new GeoCoordinate(52.51992283388972, 13.351393081247807) };
    m_startPoint = new GeoCoordinate(52.50920455902815, 13.351180600002408);
    m_endPoint = new GeoCoordinate(52.521314984187484, 13.350122384727001);
    uploadRouteGeometryOnServer();
    GeoPolyline fakeRoutePolyLine = new GeoPolyline();
    fakeRoutePolyLine.add(Arrays.asList(m_fakeRoute));
    MapPolyline mapFakeRoutePolyline = new MapPolyline(fakeRoutePolyLine);
    mapFakeRoutePolyline.setLineWidth(15);
    mapFakeRoutePolyline.setLineColor(argb(255, 185, 63, 2));
    mapFakeRoutePolyline.setPatternStyle(MapPolyline.PatternStyle.DASH_PATTERN);
    m_map.addMapObject(mapFakeRoutePolyline);
    MapMarker startMapMarker = new MapMarker(m_startPoint);
    MapMarker endMapMarker = new MapMarker(m_endPoint);
    m_map.addMapObject(startMapMarker);
    m_map.addMapObject(endMapMarker);
}
Also used : MapMarker(com.here.android.mpa.mapping.MapMarker) GeoCoordinate(com.here.android.mpa.common.GeoCoordinate) MapPolyline(com.here.android.mpa.mapping.MapPolyline) GeoPolyline(com.here.android.mpa.common.GeoPolyline)

Example 10 with MapMarker

use of com.here.android.mpa.mapping.MapMarker in project here-android-sdk-examples by heremaps.

the class MapFragmentView method addMapMarkerObject.

/**
 * create a MapMarker and add the MapMarker to active map view.
 */
private void addMapMarkerObject() {
    // create an image from cafe.png.
    Image marker_img = new Image();
    try {
        marker_img.setImageResource(R.drawable.cafe);
    } catch (IOException e) {
        e.printStackTrace();
    }
    // create a MapMarker centered at current location with png image.
    MapMarker marker = new MapMarker(m_map.getCenter(), marker_img);
    /*
         * Set MapMarker draggable.
         * How to move to?
         * In order to activate dragging of the MapMarker you have to do a long press on
         * the MapMarker then move it to a new position and release the MapMarker.
         */
    marker.setDraggable(true);
    marker.setTitle("MapMarker id: " + mapMarkerCount++);
    // add a MapMarker to current active map.
    m_map.addMapObject(marker);
    m_map_markers.add(marker);
}
Also used : MapMarker(com.here.android.mpa.mapping.MapMarker) IOException(java.io.IOException) Image(com.here.android.mpa.common.Image)

Aggregations

MapMarker (com.here.android.mpa.mapping.MapMarker)13 GeoCoordinate (com.here.android.mpa.common.GeoCoordinate)7 Image (com.here.android.mpa.common.Image)6 IOException (java.io.IOException)5 CLE2PointGeometry (com.here.android.mpa.customlocation2.CLE2PointGeometry)3 RouteWaypoint (com.here.android.mpa.routing.RouteWaypoint)3 PointF (android.graphics.PointF)2 GeoBoundingBox (com.here.android.mpa.common.GeoBoundingBox)2 CLE2Geometry (com.here.android.mpa.customlocation2.CLE2Geometry)2 CLE2Request (com.here.android.mpa.customlocation2.CLE2Request)2 NavigationManager (com.here.android.mpa.guidance.NavigationManager)2 Map (com.here.android.mpa.mapping.Map)2 CoreRouter (com.here.android.mpa.routing.CoreRouter)2 RoutePlan (com.here.android.mpa.routing.RoutePlan)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Bitmap (android.graphics.Bitmap)1 NonNull (androidx.annotation.NonNull)1 Nullable (androidx.annotation.Nullable)1 GeoPolyline (com.here.android.mpa.common.GeoPolyline)1