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