Search in sources :

Example 1 with MapMarker

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

the class MapFragmentView method createMapMarker.

/**
 * create a MapMarker and add the MapMarker to active map view.
 */
private void createMapMarker() {
    // 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.
    m_map_marker = new MapMarker(m_map.getCenter(), marker_img);
    // add a MapMarker to current active map.
    m_map.addMapObject(m_map_marker);
}
Also used : MapMarker(com.here.android.mpa.mapping.MapMarker) IOException(java.io.IOException) Image(com.here.android.mpa.common.Image)

Example 2 with MapMarker

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

the class MapFragmentView method addGeometry.

private void addGeometry() {
    // add some geometry to map using map center
    GeoCoordinate center = m_map.getCenter();
    // Create point geometry
    CLE2PointGeometry geometry = new CLE2PointGeometry(center);
    // Create map marker object
    MapMarker mapMarker = new MapMarker(center);
    m_geometryList.add(geometry);
    m_map.addMapObject(mapMarker);
}
Also used : MapMarker(com.here.android.mpa.mapping.MapMarker) GeoCoordinate(com.here.android.mpa.common.GeoCoordinate) CLE2PointGeometry(com.here.android.mpa.customlocation2.CLE2PointGeometry)

Example 3 with MapMarker

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

the class MapFragmentView method proximitySearch.

/**
 * Demonstration of the proximity search feature.
 * Search for all geometries from the center of the map in the desired search radius.
 */
private void proximitySearch() {
    clearMap();
    MapCircle searchCircle = new MapCircle(m_radiusSeekBar.getProgress() + 1, m_map.getCenter());
    searchCircle.setFillColor(Color.argb(64, 0, 0, 255));
    m_map.addMapObject(searchCircle);
    // create proximity search request using map center as center.
    CLE2ProximityRequest request = new CLE2ProximityRequest(m_layerEdit.getText().toString(), m_map.getCenter(), m_radiusSeekBar.getProgress() + 1);
    // set desired connectivity mode
    // if the connectivity mode is OFFLINE, the geometries will be searched in local storage,
    // otherwise in remote storage.
    request.setConnectivityMode((CLE2Request.CLE2ConnectivityMode) m_connectivityModeSpinner.getSelectedItem());
    // execute the reques
    request.execute(new CLE2Request.CLE2ResultListener() {

        @Override
        public void onCompleted(@Nullable CLE2Result cle2Result, @NonNull String error) {
            if (!error.equalsIgnoreCase("none") || cle2Result == null) {
                Toast.makeText(m_activity, "Error : " + error, Toast.LENGTH_LONG).show();
                return;
            }
            for (CLE2Geometry geometry : cle2Result.getGeometries()) {
                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) CLE2ProximityRequest(com.here.android.mpa.customlocation2.CLE2ProximityRequest) CLE2Request(com.here.android.mpa.customlocation2.CLE2Request) CLE2Geometry(com.here.android.mpa.customlocation2.CLE2Geometry) CLE2Result(com.here.android.mpa.customlocation2.CLE2Result) CLE2PointGeometry(com.here.android.mpa.customlocation2.CLE2PointGeometry) MapCircle(com.here.android.mpa.mapping.MapCircle)

Example 4 with MapMarker

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

the class MapFragmentView method calculateAndStartNavigation.

private void calculateAndStartNavigation() {
    if (m_map == null) {
        Toast.makeText(m_activity, "Map is not ready yet", Toast.LENGTH_SHORT).show();
        return;
    }
    if (NavigationManager.getInstance().getRunningState() == NavigationManager.NavigationState.RUNNING) {
        Toast.makeText(m_activity, "Navigation is currently running", Toast.LENGTH_SHORT).show();
        return;
    }
    final RoutePlan routePlan = new RoutePlan();
    // these two waypoints cover suburban roads
    routePlan.addWaypoint(new RouteWaypoint(new GeoCoordinate(48.960497, 2.47351)));
    routePlan.addWaypoint(new RouteWaypoint(new GeoCoordinate(48.976, 2.49162)));
    // calculate a route for navigation
    CoreRouter coreRouter = new CoreRouter();
    coreRouter.calculateRoute(routePlan, new CoreRouter.Listener() {

        @Override
        public void onCalculateRouteFinished(List<RouteResult> list, RoutingError routingError) {
            if (routingError == RoutingError.NONE) {
                Route route = list.get(0).getRoute();
                m_currentRoute = new MapRoute(route);
                m_map.addMapObject(m_currentRoute);
                // move the map to the first waypoint which is starting point of
                // the route
                m_map.setCenter(routePlan.getWaypoint(0).getNavigablePosition(), Map.Animation.NONE);
                // setting MapUpdateMode to RoadView will enable automatic map
                // movements and zoom level adjustments
                NavigationManager navigationManager = NavigationManager.getInstance();
                navigationManager.setMapUpdateMode(NavigationManager.MapUpdateMode.ROADVIEW);
                // adjust tilt to show 3D view
                m_map.setTilt(80);
                // adjust transform center for navigation experience in portrait
                // view
                m_mapTransformCenter = new PointF(m_map.getTransformCenter().x, (m_map.getTransformCenter().y * 85 / 50));
                m_map.setTransformCenter(m_mapTransformCenter);
                // create a map marker to show current position
                Image icon = new Image();
                m_positionIndicatorFixed = new MapMarker();
                try {
                    icon.setImageResource(R.drawable.gps_position);
                    m_positionIndicatorFixed.setIcon(icon);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                m_positionIndicatorFixed.setVisible(true);
                m_positionIndicatorFixed.setCoordinate(m_map.getCenter());
                m_map.addMapObject(m_positionIndicatorFixed);
                m_mapFragment.getPositionIndicator().setVisible(false);
                navigationManager.setMap(m_map);
                // listen to real position updates. This is used when RoadView is
                // not active.
                PositioningManager.getInstance().addListener(new WeakReference<>(mapPositionHandler));
                // listen to updates from RoadView which tells you where the map
                // center should be situated. This is used when RoadView is active.
                navigationManager.getRoadView().addListener(new WeakReference<>(roadViewListener));
                // listen to navigation manager events.
                navigationManager.addNavigationManagerEventListener(new WeakReference<>(navigationManagerEventListener));
                navigationManager.addLaneInformationListener(new WeakReference<>(m_laneInformationListener));
                // start navigation simulation travelling at 13 meters per second
                navigationManager.simulate(route, 13);
            } else {
                Toast.makeText(m_activity, "Error:route calculation returned error code: " + routingError, Toast.LENGTH_LONG).show();
            }
        }

        @Override
        public void onProgress(int i) {
        }
    });
}
Also used : MapRoute(com.here.android.mpa.mapping.MapRoute) NavigationManager(com.here.android.mpa.guidance.NavigationManager) MapMarker(com.here.android.mpa.mapping.MapMarker) PointF(android.graphics.PointF) CoreRouter(com.here.android.mpa.routing.CoreRouter) GeoCoordinate(com.here.android.mpa.common.GeoCoordinate) IOException(java.io.IOException) RouteWaypoint(com.here.android.mpa.routing.RouteWaypoint) Image(com.here.android.mpa.common.Image) RouteWaypoint(com.here.android.mpa.routing.RouteWaypoint) RoutingError(com.here.android.mpa.routing.RoutingError) RouteResult(com.here.android.mpa.routing.RouteResult) WeakReference(java.lang.ref.WeakReference) RoutePlan(com.here.android.mpa.routing.RoutePlan) Route(com.here.android.mpa.routing.Route) MapRoute(com.here.android.mpa.mapping.MapRoute)

Example 5 with MapMarker

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

the class MapFragmentView method calculateRoute.

private void calculateRoute(GeoCoordinate startNavPoint, GeoCoordinate endNavPoint) {
    m_map.addMapObject(new MapMarker(startNavPoint));
    m_map.addMapObject(new MapMarker(endNavPoint));
    m_routePlan = new RoutePlan();
    m_routePlan.addWaypoint(new RouteWaypoint(startNavPoint));
    m_routePlan.addWaypoint(new RouteWaypoint(endNavPoint));
    RouteOptions m_routeOptions = new RouteOptions();
    m_routeOptions.setTransportMode(RouteOptions.TransportMode.CAR).setRouteType(RouteOptions.Type.SHORTEST);
    m_routePlan.setRouteOptions(m_routeOptions);
    CoreRouter m_router = new CoreRouter();
    m_router.calculateRoute(m_routePlan, new RouterListener(m_activity));
}
Also used : MapMarker(com.here.android.mpa.mapping.MapMarker) CoreRouter(com.here.android.mpa.routing.CoreRouter) RoutePlan(com.here.android.mpa.routing.RoutePlan) RouteWaypoint(com.here.android.mpa.routing.RouteWaypoint) RouteOptions(com.here.android.mpa.routing.RouteOptions)

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