Note that there are some explanatory texts on larger screens.

plurals
  1. POObtain the latitude and longitude using the pincode on google maps
    primarykey
    data
    text
    <p>I have a requirement to loading a Google map location given the pin code or area code. I've tried using the Geocoder method to find the latitude and longitude using a given address. This works when a location or area is given, but is not working for the pincode (specifically India). Is there is any method or way to find the latitude and longitude of a given area using the pincode. </p> <p>This is specific to a map to be loaded on android, using the mapview.</p> <p>The code i've written is given as:</p> <pre><code>package com.example.geocodingexample; import java.io.IOException; import java.util.List; import java.util.Locale; import android.location.Address; import android.location.Geocoder; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.widget.LinearLayout; import android.widget.Toast; import com.google.android.maps.GeoPoint; import com.google.android.maps.MapActivity; import com.google.android.maps.MapController; import com.google.android.maps.MapView; public class MainActivity extends MapActivity { MapView mapView; MapController mapController; GeoPoint p; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mapView = (MapView) findViewById(R.id.mapview); mapController = mapView.getController(); mapView.setBuiltInZoomControls(true); mapController = mapView.getController(); mapController.setZoom(14); Geocoder geoCoder = new Geocoder(this, Locale.getDefault()); try { List&lt;Address&gt; addresses = geoCoder.getFromLocationName("karnataka", 1); String add = ""; if (addresses.size() &gt; 0) { p = new GeoPoint((int) (addresses.get(0).getLatitude() * 1E6), (int) (addresses.get(0).getLongitude() * 1E6)); mapController.animateTo(p); mapView.invalidate(); Log.i("latitude obtained", String.valueOf(p.getLatitudeE6())); Log.i("longitude obtained", String.valueOf(p.getLongitudeE6())); Toast.makeText(this, "lat obtained", Toast.LENGTH_SHORT).show(); } } catch (IOException e) { e.printStackTrace(); } } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; } @Override protected boolean isRouteDisplayed() { // TODO Auto-generated method stub return false; } </code></pre> <p>}</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.
 

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