Reputation: 217
Dears,
I have a map view that covers the whole screen. On the top of it, there is a view pager. The view pager consist of two parts, top 40% and bottom 60%, the top one is just a transparent view.
While swiping the view pager, marker displayed on map should be located to middle of transparent top view 40%.
This image describe the story:
How to achieve this? I tried this, but with no luck:
public void FollowVehicle(clsFollowMode vehicle){
final LatLng vehiclePosition = new LatLng(vehicle.getLatitude(), vehicle.getLongtitude());
Marker vehicleMarker = myGMap.addMarker(new MarkerOptions()
.position(vehiclePosition)
.title(vehicle.getDeviceName())
.snippet(String.valueOf(vehicle.getSpeed()))
.icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_vehicle_follow)));
float zoom_lvl = myGMap.getCameraPosition().zoom;
double dpPerdegree = 256.0*Math.pow(2, zoom_lvl)/170.0;
double screen_height = (double) mapContainer.getHeight();
double screen_height_30p = -20.0*screen_height/100.0;
double degree_30p = screen_height_30p/dpPerdegree;
LatLng centerlatlng = new LatLng( vehiclePosition.latitude + degree_30p, vehiclePosition.longitude );
myGMap.animateCamera( CameraUpdateFactory.newLatLngZoom( centerlatlng, 15 ), 1000, null);
}
Any help? the above solution found here.
Regards,
Upvotes: 1
Views: 669
Reputation: 41119
If I understood you correctly, then your problem is the fact that you placed the map as full screen fragmnet, and on top of this you placed the ViewPager
. as a result when you center on the marker the map does that but the marker is under the ViewPager
.
You can trick the map into thinking that it has a smaller size then it really is, by using the GoogleMap.setPadding
method, you can read more about it here:
https://developers.google.com/maps/documentation/android/map#map_padding
Upvotes: 0