Get Latitude / Longitude from Address with Accuracy
It's true, businesses are excluded from Geocoding API. If you need a location for certain business just use the Places API.
E.g.
https://maps.googleapis.com/maps/api/place/textsearch/json?query=Shop%20No%2056%2C%20Sector%2014%2C%20Haryana%2C%20Gurgaon%2C%20IN&key=YOUR_API_KEY
Get address from Geocode latitude and longitude
Use reverse_geocode_by
. It's all in here: https://github.com/alexreisner/geocoder
Getting latitude & longitude from address in android
i don it ... :)
only sequence is incorrect ...
first give street address than city name and than state ... it give me correct latitude and longitude from address .. :)
and change
Geocoder geoCoder = new Geocoder(MapClass.this, Locale.getDefault());
to
Geocoder geoCoder = new Geocoder(MapClass.this);
thanks, all of you for your time ...
How to get Latitude and Longitude from address name
create a method that returns a JSONObject with the response of the HTTP Call like following
public static JSONObject getLocationInfo(String address) {
StringBuilder stringBuilder = new StringBuilder();
try {
address = address.replaceAll(" ","%20");
HttpPost httppost = new HttpPost("http://maps.google.com/maps/api/geocode/json?address=" + address + "&sensor=false");
HttpClient client = new DefaultHttpClient();
HttpResponse response;
stringBuilder = new StringBuilder();
response = client.execute(httppost);
HttpEntity entity = response.getEntity();
InputStream stream = entity.getContent();
int b;
while ((b = stream.read()) != -1) {
stringBuilder.append((char) b);
}
} catch (ClientProtocolException e) {
} catch (IOException e) {
}
JSONObject jsonObject = new JSONObject();
try {
jsonObject = new JSONObject(stringBuilder.toString());
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return jsonObject;
}
now pass that JSONObject to getLatLong() method like following
public static boolean getLatLong(JSONObject jsonObject) {
try {
longitute = ((JSONArray)jsonObject.get("results")).getJSONObject(0)
.getJSONObject("geometry").getJSONObject("location")
.getDouble("lng");
latitude = ((JSONArray)jsonObject.get("results")).getJSONObject(0)
.getJSONObject("geometry").getJSONObject("location")
.getDouble("lat");
} catch (JSONException e) {
return false;
}
return true;
}
Related Topics
What Privacy-Violating or Device-Changing Things How to Do on an Iphone
iOS - Cydia Open Command and Its Counterpart
How to Pretty Print Swift Dictionaries to the Console
How to Make Uibutton's Text Alignment Center? Using Ib
How to Remove All Navigationbar Back Button Title
iOS Certificate Pinning with Swift and Nsurlsession
How to Use Cocoapods with Playground
How to Convert .Dae to .Scn Files in Scenekit
iOS Facebook Sdk 4.0 Login Error Code 304
iOS Simulator Display Scaled Incorrectly
How to Analyze Stack Trace Info of a Thread
Copy Text to Clipboard with iOS
How to Convert Nsinteger to Nsstring Datatype
How to Add Private Key to the Distribution Certificate