Cannot modify HERE Maps rerouting route options - android

When using the reroute listener in HERE maps, I cannot seems to figure out how to modify the RouteResult that is given by onRerouteEnd. When I plot it on the map it goes through bodies of water, which I'm guessing is because the transport mode hasn't been set. Here is what I have attempted:
private NavigationManager.RerouteListener m_reroutinglistener = new
NavigationManager.RerouteListener() {
#Override
public void onRerouteBegin(){
}
#Override
public void onRerouteEnd(RouteResult routeResult){
routeResult.getRoute().getRoutePlan().getRouteOptions().setTransportMode( RouteOptions.TransportMode.PEDESTRIAN );
routeResult.getRoute().getRoutePlan().getRouteOptions().setRouteType( RouteOptions.Type.SHORTEST );
MapRoute newRoute = new MapRoute( routeResult.getRoute() );
newRoute.setColor( Color.CYAN );
map.addMapObject( newRoute );
}
};

You shout not modify routeResult, this object represents result of the route calculation. What you need is to set routeOptions with all its parameters before route is calculated, e.g. like this.

Related

Android get properties for polygon from GeoJson

Im adding GeoJsonLayer to Google map on my application. This json contains coordinates for polygon and properties for each polygon. What I need is to get those properties when polygon is clicked. This is the code Im using to achieve that.
GeoJsonLayer jsonLayer = new GeoJsonLayer(mMap, geoJSON);
jsonLayer.addLayerToMap();
jsonLayer.setOnFeatureClickListener(new GeoJsonLayer.GeoJsonOnFeatureClickListener() {
#Override
public void onFeatureClick(final com.google.maps.android.data.Feature feature) {
mMap.setOnPolygonClickListener(new GoogleMap.OnPolygonClickListener() {
#Override
public void onPolygonClick(Polygon polygon) {
for (Object s : feature.getProperties()) {
Log.d("getProperties", "getProperties = " + s.toString());
}
}
});
}
});
The problem is that it returns all properties. I want it to return properties only for the polygon I clicked.
Also its possible to draw polygons with user input. When I click on those polygons it triggers onPolygonClick() inside jsonLayer.setOnFeatureClickListener(). How to check if clicked polygon is from jsonLayer?

Reroute bannerinstruction while offroutelistener detected

I am overriding allowreroutefrom() function from routelistener to pick up my custom route when offroutelistener is detected. I am returning false and starting the new navigation with custom computed route. But I want to show the Rerouting bannerinstruction when reroute happens. How to give our own instruction in banner?
The InstructionView has showRerouteState() and hideRerouteState() methods that you can use:
#Override
public boolean allowRerouteFrom(Point offRoutePoint) {
// Fetch new route
InstructionView instructionView = findViewById(R.id.instructionView);
instructionView.showRerouteState();
return false;
}

Make graphics clickable instead of create new graphics in map

So, I have a map with a MapOnTouchListener on it. I have overriden the OnSingleTap method (allPoints is an array where all markers are added for a non related to this question functionality):
#Override
public boolean onSingleTap(MotionEvent point) {
Point mapPoint=view.toMapPoint(point.getX(), point.getY());
new GeocoderAsynckTask(mapPoint,view).execute(mapPoint);
SpatialReference sp = SpatialReference.create(SpatialReference.WKID_WGS84);
Point p1Done=(Point) GeometryEngine.project(mapPoint, mvHelper.getMapView().getSpatialReference(), sp);
allPoints.add(p1Done);
return super.onSingleTap(point);
}
That GeoCoderAsyncTask translates the coords of the point to an address, and adds a marker to the map. The geocoding is done just right, I get my address and in PostExecute method I add the marker to the map:
protected void onPostExecute(String address) {
mProgressDialog.dismiss();
Toast.makeText(ctx,address,Toast.LENGTH_LONG).show();
SpatialReference sp = SpatialReference.create(SpatialReference.WKID_WGS84);
Point p1Done=(Point) GeometryEngine.project(point, mvHelper.getMapView().getSpatialReference(), sp);
mvHelper.addMarkerGraphic(p1Done.getY(), p1Done.getX(), "Location", address, android.R.drawable.ic_menu_myplaces, null, false, 1);
}
The problem is, I want the markers to be clickable, but if I click them, another marker is added. I have tried to nullify the MapOnTouchListener, but that way, no marker is added, and no click on marker is detected...
How could I acomplish that?
Thank you.
EDIT:
if I simply set a SingleTapListener on the map at the start of the execution of the app instead of setting my MapOnTouchListener, the markers are created, and are clickable:
mMapView.setOnSingleTapListener(new OnSingleTapListener() {
#Override
public void onSingleTap(float v, float v1) {
mMapView.createIcon(v,v1);
}
});
After that, by clicking a button, I set the MapOnTouchListener, because I need another functionality (create an envelope and store the points in that envelope inside an array). After doing that, I try to nullify the MapOnTouchListener, and after that set the singleTapListener as in the start of the execution...and the markers are created, but cannot be clicked!!

Android ARCGIS Shape file labeling polylines

I have my ARCGIS android app displaying a polyline shapefile file - a roading network in this case.
The shape file has a field that contains the name of the road "ROAD_NAME' - the question i have is how do i create a layer to have the road name automatically displayed?
cheers
B
I also tried to display labels on the map.
By my experiment, there are 2 ways. I realized it.One way is that draw those labels programmatically on the map. but it needs a lot of effort. I did it, it is not pretty. I think so.
public class LabelLayer extends GraphicsLayer {
...
private void showLabel(final FeatureLayer fly, final QueryParameters query,final String labelField) {
new Thread(new Runnable() {
#Override
public void run() {
fly.getFeatureTable().queryFeatures(query, new CallbackListener<FeatureResult>() {
#Override
public void onCallback(FeatureResult objects) {
Iterator<Object> fet=objects.iterator();
while (fet.hasNext()){
Feature f=(Feature) fet.next();
Geometry geom= f.getGeometry();
Point p=null;
switch (geom.getType()){
case POINT:p=(Point)geom;break;
case POLYLINE: Polyline polyline=(Polyline)geom;break;
case POLYGON: p= GeometryEngine.getLabelPointForPolygon((Polygon)geom,mapView.getSpatialReference());break;
default:break;
}
txtSymbol.setFontWeight(FontWeight.BOLD);
txtSymbol.setColor(Color.DKGRAY);
txtSymbol.setText(f.getAttributeValue(labelField).toString());
Graphic gr = new Graphic(p, txtSymbol);
LabelLayer.this.addGraphic(gr);
}
}
#Override
public void onError(Throwable throwable) {
}
});
}
}).start();
}
...
}
this class should be implemented in onDraw() method.
the second is that use the tpk of ArcGIS.
I think it would be better much.

Enabling "navigation" mode in skobbler Android API

I can't find a way to make my app, which currently implements SKmaps to the point of showing a route, show the route and follow the route like a car navigator.
example:
This is my "route loading" method:
#Override
public void onAllRoutesCompleted() {
SKNavigationSettings navigationSettings = new SKNavigationSettings();
navigationSettings.setNavigationType(SKNavigationSettings.SKNavigationType.REAL);
navigationSettings.setNavigationMode(SKNavigationSettings.SKNavigationMode.CAR);
navigationSettings.setCcpAsCurrentPosition(true);
navigationSettings.setFcdEnabled(true);
SKNavigationManager navigationManager = SKNavigationManager.getInstance();
navigationManager.setMapView(mapView);
navigationManager.setNavigationListener(MainActivity.this);
navigationManager.startNavigation(navigationSettings);
}
found it on the demo app code.
mapView.getMapSettings().setMapDisplayMode(SKMapSettings.SKMapDisplayMode.MODE_3D);

Categories

Resources