Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8932133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:16:23+00:00 2026-06-15T09:16:23+00:00

I am trying to use the Google maps API on my android app. I

  • 0

I am trying to use the Google maps API on my android app. I have set an overlay item at a particular geopoint co-ordinate. On opening the activity, it uses the default mapview of the google map with the correct location of the overlay item for that geotpoint. My question is, how do I set the view to be zoomed in for that geopoint so one would actually see the location in a better fashion rather than having to manually zoom in by tracing the overlay item. I wish to zoom it so I can see the local area so the user can at least derive useful information from it.
My code is as follows:

/—- HelloItemizedOverlay.java ——-/

public class HelloItemizedOverlay extends ItemizedOverlay<OverlayItem> {

private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
Context mContext;

public void addOverlay(OverlayItem overlay)
{
    mOverlays.add(overlay);
    populate();
}

public HelloItemizedOverlay(Drawable defaultMarker) {
    super(boundCenterBottom(defaultMarker));
    // TODO Auto-generated constructor stub
}
public HelloItemizedOverlay(Drawable defaultMarker, Context context) {
      super(boundCenterBottom(defaultMarker));
      mContext = context;
    }


@Override
protected OverlayItem createItem(int i) {
    // TODO Auto-generated method stub
    return mOverlays.get(i);
}

@Override
public int size() {
    // TODO Auto-generated method stub
    return mOverlays.size();
}

@Override
protected boolean onTap(int index) {
  OverlayItem item = mOverlays.get(index);
  AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
  dialog.setTitle(item.getTitle());
  dialog.setMessage(item.getSnippet());
  dialog.show();
  return true;
}
}

/*—- MainActivity.java —- */

public class MainActivity extends MapActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    MapView view = (MapView)findViewById(R.id.themap);
    view.setBuiltInZoomControls(true);

    final GeoPoint point = new GeoPoint(19240000,-99120000);
    OverlayItem overlayitem = new OverlayItem(point, "Hola, Mundo!", "I'm in Mexico City!");

    GeoPoint point2 = new GeoPoint(35410000, 139460000);
    OverlayItem overlayitem2 = new OverlayItem(point2, "Sekai, konichiwa!", "I'm in Japan!");


    final MapController control = view.getController();
    LocationManager manager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
    LocationListener listener = new LocationListener() {

        @Override
        public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onProviderEnabled(String arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onProviderDisabled(String arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onLocationChanged(Location arg0) {
            // TODO Auto-generated method stub
            control.setCenter(point);
        }
    };

    manager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, listener);
    List<Overlay> mapOverlays = view.getOverlays();
    Drawable drawable = this.getResources().getDrawable(R.drawable.ic_launcher);
    HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(drawable, this);


    itemizedoverlay.addOverlay(overlayitem2);
    itemizedoverlay.addOverlay(overlayitem);
    mapOverlays.add(itemizedoverlay);




}



@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}

@Override
protected boolean isRouteDisplayed() {
    // TODO Auto-generated method stub
    return false;
}

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T09:16:25+00:00Added an answer on June 15, 2026 at 9:16 am

    @noobcoder I have used the same example, and if i get your question right, you can use the following method to zoom to a particular point.

    https://developers.google.com/maps/documentation/android/reference/com/google/android/maps/MapController#animateTo(com.google.android.maps.GeoPoint, java.lang.Runnable)

    It worked at least for me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

GOOGLE MAPS API V3 is what i'm trying to use. I have all the
I'm trying to use the Google Maps API in a Sinatra app. I get
I'm trying to use Google Maps API and i'm stuck here: I need an
I'm experiencing a problem while trying to use google maps api v3 (with marker
I am trying to use Google Places in Google Maps API v3, but I
I was trying to use the google maps API within some jQuery ajax, however
I'm trying to use the Google maps geocode API to return all parks for
I'm trying to use the Google Maps V3 API to create markers on a
Am trying to use google.loader.ClientLocation along with the maps api to get the location
I'm trying to use the google maps API to fetch direction times. I'm hoping

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.