Android SDK Route Navigation Customization - android

hello i'm trying to customize here navigation inside my app
is it possible to change the thickness of the route line inside the nav (
similar thread Android HereMaps SDK Route Line Thickness?
)?
is it possible to change the maximum/minimum zoom while I'm using NavigationManager.MapUpdateMode.ROADVIEW?
and finally is it possible to move mapView.positionIndicator at the bottom of the screen inside navigation?

Thickness of MapRoute object can't be adjusted.
There is no way to adjust max/min zoom level for ROADVIEW, you can try ROADVIEW_NOZOOM instead and control zooming by yourself.
Please use Map.setTransformCenter to control the map movement center (number of pixel). For example, you have an 1080*1920 screen, you can use map.setTransformCenter(new PointF((540.0), (1162.8))); to shift the map movement center lower.

Yes you can change thickness of MapRoute
If you really want to use MapRoute You can use CustomizableScheme for that :
CustomizableScheme scheme = map.createCustomizableScheme("newCustomScheme", Map.Scheme.NORMAL_DAY);
scheme.setVariableValue(CustomizableVariables.RouteStyle.ROUTESTYLE_1_WIDTH , *Width in pixels* , range);
you can check the CustomizableVariables.RouteStyle Class
if you want to use Polylines tho you can try this :
MapPolyline mp = new MapPolyline(new GeoPolyline(route.getRouteGeometry()));
mp.setLineWidth(20);
map.addMapObject(mp);

Related

Google Maps Android Circle fill not working

I'm using a MapView to display a Google Map and the trying to create a circle overlay. But for some reason the circle border is displayed but it is not filled with any color, here is what is generated using the android emulator:
Here is an idea of what I would like to achieve (i created it through the w3school online editor).
Here is the code:
LatLng center = new LatLng(-16.272425327210556,166.4380745618525);
double radius = 9944545.500957435;
CircleOptions co = new CircleOptions().center(center).clickable(false).radius((radius)).fillColor(Color.YELLOW).visible(false);
this.marker_twilight_civil = map.addCircle(co);
I tried with a different radius value and actually it works with a specific one, here i created 3 circles with different radius values, and olny one is filled, the other two are not filled.
Here is the code for the circle that is filled correctly
LatLng center = new LatLng(-16.272425356472187,166.43807456511806);
double radius = 8006044.77150472;
CircleOptions co = new CircleOptions().center(center).clickable(false).radius((radius)).fillColor(Color.GREEN).visible(true);
this.marker_night = map.addCircle(co);
Could it be a issue with the too large radius? But on the web version is working well.
It could be because the radius is too large. Google Maps uses a Mercator projection, which will skew circles if they are large enough. For technical reasons, if the shape isn't "closed" then the fill won't be applied. If the shape is too large, or too close to the highly-skewed top or bottom of the map, then the shape will break open and the fill will be ignored.
If it was truly important you could try forcing a custom Projection on Google Maps (which could avoid the skew and keep the shape closed), but this isn't a well-tread path and I can't provide a solution beyond the link:
https://developers.google.com/maps/documentation/javascript/examples/map-projection-simple

Change Google Map Offset Center

I'm trying to set the user location on the map such that it sits about 1/3 of the way up from the bottom of the screen, and when the map rotates, it will rotate around this point.
The closest I've got to achieving this is by using the setPadding() method, however, this causes the map to sort of shake when rotated, as the center point sort of 'floats' around where it actually should be. It looks quite ugly
int mapHeight = mapView.getHeight();
googleMap.setPadding(0, mapHeight / 5, 0, 0);
Is there a better way to do this?
Edit: Explained in picture below
You don't need paddings
Change mappoint X and Y values as you need you can call this where you want! may be inside your onLocationChanged like changeOffsetCenter(location.getLatitude(),location.getLongitude());
public void changeOffsetCenter(double latitude,double longitude) {
Point mappoint = mGoogleMap.getProjection().toScreenLocation(new LatLng(latitude, longitude));
mappoint.set(mappoint.x, mappoint.y-100); // change these values as you need , just hard coded a value if you want you can give it based on a ratio like using DisplayMetrics as well
mGoogleMap.animateCamera(CameraUpdateFactory.newLatLng(mGoogleMap.getProjection().fromScreenLocation(mappoint)));
}
output :
Google map v3 beta seems to fix it, using padding now properly move pivotX/pivotY for rotation
https://developers.google.com/maps/documentation/android-sdk/v3-client-migration
Accepted answer might be work of "animateCamera". Its makes "shaking of rotations" almost invisible. So more easy will be using
mMap.setPadding(leftPx, topPx, rightPx, bottomPx)
with mMap.animateCamera
or twice mMap.moveCamera(in case of changing bearing
1nd moveCamera rotate with center of device, 2nd moveCamera make correct center using padding)
Its kind of hack, while google do not fix rotation considering setPadding

Cant Zoom Desired Level In Google Maps To Fit 2 Directions In Screen

(I would want to put screenshots put my reputation is low to put them...)
Good Day.I Have two directions(markers) on google maps api(android) between which i want camera to be center,and camera being centered there.But problem is that one marker comes to one edge of screen and another marker to another edge of screen!I don't want it to be like that,i want just to zoom specified level so markers will be center in google maps view and won't be place on edges of screen.I tried to put even 0 zoom level in camera update factory of google maps,but nothing happens at all.Here is my code how do i achieve that
} finally {
com.google.android.gms.maps.model.LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
boundsBuilder.include(new LatLng(Double.parseDouble(tolat), Double.parseDouble(tolong)));
boundsBuilder.include(new LatLng(Double.parseDouble(fromlat), Double.parseDouble(fromlong)));
final LatLngBounds bounds = boundsBuilder.build();
map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0));
}
you say you tried to put 0 as the zoom level. You mean this call CameraUpdateFactory.newLatLngBounds(bounds, 0) right?
The second parameter is the padding not the zoom level. Set it up (example to 10) and you have a padding to the outer edges.
https://developers.google.com/android/reference/com/google/android/gms/maps/CameraUpdateFactory
I hope it helps.

Google Maps Android V2 padding with rotation around user

I'm developing an app that is using a google map to show your location. I want to rotate the map around the users location. I use getOrientation(R, orientation) (and adjust for true north) to get the device rotation which is working fine but i want the user location to be near the bottom of the screen. I have set the padding on the map to a quarter of the screen height
mMap.setPadding(0,screenHeight/4,0,0);
What hI have noticed is that the rotation is still done around the point at the centre of the screen NOT the padded centre.
This is the code I'm using in onSensorChanged
currentZoom = mMap.getCameraPosition().zoom;
CameraPosition currentPlace = new CameraPosition.Builder()
.target(new LatLng(currentNode.getLatitude(), currentNode.getLongitude()))
.bearing(degrees).tilt(60).zoom(currentZoom).build();
mMap.stopAnimation();
mMap.animateCamera(CameraUpdateFactory.newCameraPosition(currentPlace),40,null);
Is there a way to change the anchor point of camera rotation?
I was trying to solve this problem for several hours. The only solution I found is not very good, but it works:
For example, if you want to move the user 200dp below the center:
1) Set map fragment height to its height + 200dp (Then the map will go 200dp below the screen)
2) This works fine, but it hides Google logo. To preserve the Google logo, set map padding top and bottom to 200dp.
mGoogleMap.setPadding(0, dp2px(200),0 , dp2px(200));
That solves the problem

android change bounds of google map

I am working on a project in android which requires me to change the bounds of a google map(from bottom only). Currently I am trying by adding padding at the bottom, but this process is slow and the screen also flickers.
Is there any better way to do this?
I would like the user to be able to drag the bottom of the map to change the bounds.
I see a lot of AJAX/JS resouces, but this is a native component.
Best
I think it will be a huge amount of work to let the user actually drag the bottom of your map view. what is much easier and faster to do is to create to 2 map fragments of your map and on click of the map change the fragment back and foreword between the two.
this way the user can change the size of the map the he works with.
You can zoom map to added points.
Here is some pseudo code:
LatLngBounds.Builder bc = new LatLngBounds.Builder();
for (LatLng item : points) {
bc.include(item);
}
LatLngBounds bounds = bc.build();
#SuppressWarnings("deprecation")
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds,
getWindowManager().getDefaultDisplay().getWidth(),
getWindowManager().getDefaultDisplay().getHeight(), 50);
mMap.moveCamera(cu);
Bounds will be changed to added points. Help It hope

Categories

Resources