1

I have recently deployed Google map API in my android application. The problem is that the marker placed on the map is not visible until user scroll/navigate over the view where map's fragment is deployed.

problem is" How to focus the Google map to the marker of a specific location on initializing.

EDITED: 25 AUGUST 2017

I have placed the marker for a particular location using following this blog post

PROBLEM

I am trying to view my marker directly when a user sees the map. Not by scrolling the map to see the marker.

Shubham AgaRwal
  • 4,355
  • 8
  • 41
  • 62

1 Answers1

2

You need to animate or move the map to the place where the marker is placed. I have pasted a snippet which should help you achieve that. Implement OnMapReadyCallback interfere and once the map is ready you should get a callback thru onMapReady(). This code only for your reference. You can place the marker related code wherever you need and works fine.

@Override
public void onMapReady(GoogleMap googleMap) {
    LatLng location = new LatLng(<latitude>, <longitude>);
    CameraPosition target = CameraPosition.builder().target(location).zoom(15).build();
    googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(target), 5000, null);
    googleMap.addMarker(new MarkerOptions().position(location));
}
Sameer Khan
  • 637
  • 6
  • 15