How can I change marker position and change google Map view with it

Viewed 289

I am trying to set my android App Google Map View to bottom of the screen but it does not changes its position to bottom. I am trying to replicate a GoogleMap/Waze kind of navigation feature in my Android Application.

Marker Code: Here I set the marker position to custom position according to user position and set a custom icon.

MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(userlatLng);
markerOptions.icon(markerIcon);
markerOptions.rotation(userlocation.getBearing());
markerOptions.title("Current Position");
markerOptions.anchor((float) 0.5, (float) 0.5);
markerOptions.flat(true);
currentLocationMarker = map.addMarker(markerOptions);

Camera Position I am changing the Camera position accourding to User current location with the zoom level of 20.

CameraPosition cameraPosition = new CameraPosition.Builder()
                .target(userlatLng)
                .zoom(20)
                .bearing(userlocation.getBearing())
                .tilt(45)
                .build();
        map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));

I wanted to ask how can I drop the icon to the bottom of the screen and show the remaining route on wide angle screen.

Mobile App Current view that is showing the Icon in the middle

Mobile App Icon Position that I want to set

3 Answers
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(userlatLng);
markerOptions.icon(markerIcon);
markerOptions.anchor(whereIwantIt,whereIwantIt); // You need to add an anchor tag
markerOptions.rotation(userlocation.getBearing());
markerOptions.title("Current Position");
markerOptions.anchor((float) 0.5, (float) 0.5);
markerOptions.flat(true);
currentLocationMarker = map.addMarker(markerOptions);

You need to add anchor tag. https://developers.google.com/maps/documentation/android-sdk/marker

MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(userlatLng);
markerOptions.icon(markerIcon);
markerOptions.rotation(userlocation.getBearing());
markerOptions.title("Current Position");
markerOptions.anchor((float) 0.5, (float) 0.5);
markerOptions.flat(true);
currentLocationMarker = map.addMarker(markerOptions);
currentLocationMarker.setPosition(userlatLng);

you can wrap google map in a ScrollView but disable scrollable. enter image description here

Related