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

  • Home
  • SEARCH
  • 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 9260747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:58:21+00:00 2026-06-18T12:58:21+00:00

I can display the map and have the button show on the map, when

  • 0

I can display the map and have the button show on the map, when I tap it it does exactly what I want it to do. In my code I have this:

 googleMap.setMyLocationEnabled(true);
 googleMap.getMyLocation();

Is there a way to do this automatically upon loading the map, without having to tap the zoom into location button?

I researched this and found examples on getting the users location, but the examples I found didn’t do what I wanted, I am not sure it was code for V2 maps. Surely there must be an easy, code minimal way to do this by now?

I read through This post on Stackoverflow, but I have no idea what to do with this code:

googleMap.getCameraPosition().target

target takes a location I think?

Any assistance is appreciated!

Thanks!

  • 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-18T12:58:22+00:00Added an answer on June 18, 2026 at 12:58 pm

    I solved this by using the following code:

       lm =(LocationManager) getSystemService(Context.LOCATION_SERVICE);
        Criteria crit = new Criteria();
    
        towers = lm.getBestProvider(crit, false);
    
        Location location = lm.getLastKnownLocation(towers);
    
        if(location != null){
    
            Double glat = location.getLatitude();
            Double glon = location.getLongitude();
    
        }
    

    Then setting the map up:

    CameraPosition cp = new CameraPosition.Builder()
            .target(new LatLng(glat, glon))
            .zoom(15)
            .build();     
            googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cp));
    

    This get the users location, and when the map loads, it automatically zooms into that location, where you should see a blue dot where you sit!

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

Sidebar

Related Questions

The problem that I have is that I want to display a map of
I am using Google Maps V3 API to display my map. Problem: How can
I can display a simple Visual Basic inputbox from a PowerShell script like this:
I want to develop JSF page which can display the swap size if the
I have a map view with annotations, and these annotations display a callout. When
I have jQuery mobile working with google maps so that I can display one,
I want to develop an application in iPhone and Android both which can display
I have a map application that uses jQuery to show/hide some map controls upon
I have one application. I need to display a map view when we click
I have done one project in android which is to display map using GOOGLE

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.