How do I find out my coordinates?

Good evening, the problem is this. How to find out your coordinates Google map api v2 android. And how do I put another marker instead of the standard marker indicating my location?

Author: Юрий94, 2013-05-06

3 answers

God, they gave the newbie some advice... Yuri, first of all, the manifest must contain the correct permissions and your ID that you received for the debug version of the application. Without this, you will not even have the cards shown in the Activity. Next: to find out your coordinates, you need to access the location providers. Here you can already determine what you need. GPS or just over the network/Wi-Fi. In my app, the function checks for GPS and sets the listener. I also set the listener coordinates and over the network (Internet):

private void checkGPS() {
    mLocationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);

    final boolean gpsEnabled = mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);

    if (!gpsEnabled && gpsAllowed)
        createGPSAlert();

    // Register the listener with the Location Manager to receive location
    // updates
    mLocationManager.requestLocationUpdates(
            LocationManager.NETWORK_PROVIDER, 1, 10, mMapDelegate);
    mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
            1, 10, mMapDelegate);
}
 2
Author: Lucky_spirit, 2013-05-07 00:04:07

Email from Google:

We are contacting you because your email address associated with the Google Maps JavaScript API v2 key is used for the following domains: ° %domain_name% As you should know, the deprecation period of three years for version 2 of the Maps JavaScript API ends in May 2013. After this date, the API will no longer be supported, and the functions may not function as expected. At some point, your maps are on V2 they may stop working completely. The good news is that Google Maps Javascript API v3 is more reliable and has more functionality than v2, and for the vast majority of sites there are no problems with migrating to V3. Therefore, we strongly recommend that you review our migration guides and also aim to migrate before May 2013.

 1
Author: vanyamelikov, 2013-05-06 20:03:49

As for your location, here it is

Location location = googleMap.getMyLocation();

As for the second one, I can't say 100% correct solution, but this layer can be disabled, as far as I know, and subscribe to listen for a location where you can place a marker in the right place.

googleMap.setOnMyLocationChangeListener(new GoogleMap.OnMyLocationChangeListener()
            {
                @Override
                public void onMyLocationChange(Location location)
                {

                }
            });

PS: Yes, the solution with the marker is not very beautiful, and I know that the older maps have a more elegant solution, but I suggested the first working option that came to mind

 0
Author: andreich, 2013-05-06 20:21:03