Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd current location to google map
    primarykey
    data
    text
    <p>I am wririting an application which obtains current location usins gps and convert it to corresponding adress.Now i want to markk this position in the google map.I can display the map but can't mark the position. this is my code</p> <pre><code>package com.gpsshoppe; import java.io.IOException; import java.util.List; import java.util.Locale; import android.content.Context; import android.location.Address; import android.location.Geocoder; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.util.Log; import android.view.Menu; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.SupportMapFragment; import com.google.android.maps.GeoPoint; public class MapActivity extends FragmentActivity { GoogleMap map; //Location location; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_map); LocationManager mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); LocationListener mlocListener = new GpsMapLocationActivity(); mlocManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, mlocListener); if (map == null) { map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)) .getMap(); map.setMyLocationEnabled(true); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.map, menu); return true; } private class GpsMapLocationActivity implements LocationListener{ @Override public void onLocationChanged(Location location) { // TODO Auto-generated method stub if (location != null) { final GeoPoint point = new GeoPoint( (int) (location.getLatitude() * 1E6), (int) (location.getLongitude() * 1E6)); String address = ConvertPointToLocation(point); address.toString(); Log.i("ADRESSS", ""+point); } } public String ConvertPointToLocation(GeoPoint point) { // TODO Auto-generated method stub String address = ""; Geocoder geoCoder=new Geocoder(getBaseContext(), Locale.getDefault()); try { List&lt;Address&gt; addresses = geoCoder.getFromLocation( point.getLatitudeE6() / 1E6, point.getLongitudeE6() / 1E6, 1); if (addresses.size() &gt; 0) { for (int index = 0; index &lt; addresses.get(0).getMaxAddressLineIndex(); index++) address += addresses.get(0).getAddressLine(index) + " "; } } catch (IOException e) { e.printStackTrace(); } return address; } @Override public void onProviderDisabled(String provider) { // TODO Auto-generated method stub } @Override public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Override public void onStatusChanged(String provider, int status, Bundle extras) { // TODO Auto-generated method stub } } } </code></pre> <p>please help me... thanks in advance..</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload