Wednesday, 15 September 2010

Location within 100 km using google maps android -


After "text" itemprop = "text">

I'm working on the Android application Google map, in which I'm looking for special address by using the following code I want if I am 100 km within my place, then get the place of the address detected, and if it is outside the boundary then it will not show me I try to get the search space within my 100 km radius I am doing Please help me out here

  Spread the private class GeocoderTask asyncTask & lt. String, zero, from list & lt; Address & gt; & Gt; {@Override from the protected list & lt; Address & gt; DoInBackground (String ... locationName) {// Geocoder class by creating an example of Geocodar Geocoder = new Geocoder (getBaseContext ()); & Lt; Address & gt; Addresses = null; Try {// //24798406, 54.7, 9 0,448 //25.452403, 55.53751 9 // matching the input text addresses, getting a maximum of 3 addresses = geocoder.getFromLocationName (locationName [0], 10, 24.861, 969, 54.857740,25.545368, 55.4,74,347); / /.getFromLocationName (place name 3], 3); } Hold (IOException e) {e.printStackTrace (); } Return addresses; } @ Override Protected Zero at PostXquate (List & Address; Address & gt; Address) {If (address == Null} addresses.size () == 0} {Toast. MakeBaseContext, "no location found", toast .LENGTH_SHORT). Show (); } // map cleans all existing markers on mMap.clear; // Adding markers to the address of each map on google muddle (int i = 0; i & lt; addresses.size (); i ++) {address address = (address) addresses.get (i); LatLng latLng; // Google Map LatLng = Create an example of GeoPoint to display in the new LatLng, (address.getLatitude (), address.getLongitude ()); String addressText = String.Format ("% s,% s", address.getMaxAddressLineIndex ()> 0 address.getAddressLine (0):? "", Address.getCountryName ()); Marker Option = New Marker Option (); MarkerOptions.position (LatLng); // markeroptions.con (bitmap descriptor feature from resource (RDWable.flug)); MarkerOptions.title (addressText); MMap.addMarker (markerOptions); // Locate the first place if (i == 0) mMap.animateCamera (CameraUpdateFactory.newLatLng (latLng)); }}}}  
= "post-text" itemprop = "text">

You can calculate the distance using this code. Here in the distance meter you can call this function and check whether the location is or not.

  Private Boolean check Fourieria (Intra rad, wave long form position, wave long to position) {place location A = new location ("Point A"); LocationA.setLatitude (fromPosition.latitude); LocationA.setLongitude (fromPosition.longitude); Location Location B = New Location ("Point B"); LocationB.setLatitude (toPosition.latitude); LocationB.setLongitude (toPosition.longitude); Int distance = (int) locationadress to (location b); If (distance / 1000 & lt; = rad) is right back; Second false return; }  

No comments:

Post a Comment