Geocoder getFromLocationName - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Geocoder getFromLocationName method.

This code example shows how to use the following methods:getFromLocationName
        geocoder = new Geocoder(new Activity());
    } 
 
    @Test 
    public void shouldRecordLastLocationName() throws Exception { 
        geocoder.getFromLocationName("731 Market St, San Francisco, CA 94103", 1);
        String lastLocationName = shadowOf(geocoder).getLastLocationName();
         
        assertEquals("731 Market St, San Francisco, CA 94103", lastLocationName);
    } 
 
    @Test 
    public void setsUpHasLocationInAddressFromLocationName() throws Exception { 
        shadowOf(geocoder).setSimulatedHasLatLong(true, true);
        Address address = geocoder.getFromLocationName("731 Market St, San Francisco, CA 94103", 1).get(0);
        assertTrue(address.hasLatitude());
        assertTrue(address.hasLongitude());
        shadowOf(geocoder).setSimulatedHasLatLong(false, false);
        address = geocoder.getFromLocationName("731 Market St, San Francisco, CA 94103", 1).get(0);
        assertFalse(address.hasLatitude());
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getFromLocationName
@RunWith(WithTestDefaultsRunner.class) 
public class GeocoderTest { 
 
    @Test 
    public void shouldRecordLastLocationName() throws Exception { 
        Geocoder geocoder = new Geocoder(new Activity());
        geocoder.getFromLocationName("731 Market St, San Francisco, CA 94103", 1);
        String lastLocationName = shadowOf(geocoder).getLastLocationName();
         
        assertEquals("731 Market St, San Francisco, CA 94103", lastLocationName);
    } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getFromLocationName
    } 
 
    /** Return List of <Address> from searched location */ 
    public static List<Address> geoDecode(String searchedLocation) {
        try { 
            Geocoder geo = new Geocoder(XmppService.getInstance().getBaseContext(), Locale.getDefault());
            List<Address> addresses = geo.getFromLocationName(searchedLocation, 10);
            if (addresses != null && addresses.size() > 0) {
               return addresses;
            } 
        } 
        catch(Exception ex) {
        } 
 
        return null; 
    } 
 
    /** launches an activity on the url */ 
    public static void launchExternal(String url) {
        Intent popup = new Intent(XmppService.getInstance(), GeoPopup.class);
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getFromLocationName
 
	private List<Address> getDestinationAddresses() throws IOException {
		List<Address> destinations = new ArrayList<Address>();
         
        Address dest1 = null;
        List<Address> destBuffer = geocoder.getFromLocationName("300 West Martin Luther King Junior Boulevard, Austin, TX", 1);
        if (destBuffer != null && destBuffer.size() > 0) {
        	dest1 = destBuffer.get(0);
        	destinations.add(dest1);
        	Log.d(TAG, "dest1: " + dest1.getAddressLine(0) + " - " + dest1.getLatitude() + ", " + dest1.getLongitude());
        } else { 
        	Log.e(TAG, "Couldn't reverse geocode dest1");
        } 
         
        Address dest2 = null;
        destBuffer = geocoder.getFromLocationName("2902 Medical Arts Street, Austin, TX", 1);
        if (destBuffer != null && destBuffer.size() > 0) {
        	dest2 = destBuffer.get(0);
        	destinations.add(dest2);
        	Log.d(TAG, "dest2: " + dest2.getAddressLine(0) + " - " + dest2.getLatitude() + ", " + dest2.getLongitude());

5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getFromLocation, getFromLocationName
@Suppress 
public class GeocoderTest extends AndroidTestCase {
 
    public void testGeocoder() throws Exception { 
        Locale locale = new Locale("en", "us");
        Geocoder g = new Geocoder(mContext, locale);
 
        List<Address> addresses1 = g.getFromLocation(37.435067, -122.166767, 2);
        assertNotNull(addresses1);
        assertEquals(1, addresses1.size());
 
        Address addr = addresses1.get(0);
        assertEquals("94305", addr.getFeatureName());
        assertEquals("Palo Alto, CA 94305", addr.getAddressLine(0));
        assertEquals("USA", addr.getAddressLine(1));
        assertEquals("94305", addr.getPostalCode());
        assertFalse(Math.abs(addr.getLatitude() - 37.4240385) > 0.1);
 
        List<Address> addresses2 = g.getFromLocationName("San Francisco, CA", 1);
        assertNotNull(addresses2);

4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getFromLocationName
		gpsActive = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
	} 
 
	 
	public DirectionDao getLocationFromAddress(String address) throws IOException{
		Geocoder geoCoder = new Geocoder(TRCardManagerApplication.getActualActivity());
		DirectionDao phisicalDirecction = null;
		List<Address> addresses = geoCoder.getFromLocationName(address, 5);
		phisicalDirecction = getAddressDirection(addresses.get(0));
		return phisicalDirecction;
	} 
	 
	 
	public void getLocationFromAddress(RestaurantSearchDao restaurantSearchDao) throws IOException{
		Geocoder geoCoder = new Geocoder(TRCardManagerApplication.getActualActivity());
		List<Address> addresses = geoCoder.getFromLocationName(restaurantSearchDao.getAddressSearch(), 5);
		restaurantSearchDao.getDirectionDao().setLocation(getLocation(addresses.get(0)));
	} 
	 
	 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getFromLocationName
    } 
 
    /** Return List of <Address> from searched location */ 
    public static List<Address> geoDecode(String searchedLocation) {
        try { 
            Geocoder geo = new Geocoder(XmppService.getInstance().getBaseContext(), Locale.getDefault());
            List<Address> addresses = geo.getFromLocationName(searchedLocation, 10);
            if (addresses != null && addresses.size() > 0) {
               return addresses;
            } 
        } 
        catch(Exception ex) {
        } 
         
        return null; 
    } 
     
    /** launches an activity on the url */ 
    public static void launchExternal(String url) {
        Intent popup = new Intent(XmppService.getInstance(), GeoPopup.class);
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getFromLocationName
			mContext = context;
		} 
 
		@Override 
		protected List<Address> doInBackground(String... params) {
			Geocoder geocoder = new Geocoder(mContext, Locale.getDefault());
 
			String locationName = params[0];
			List<Address> addresses = null;
			try { 
				// Call the synchronous getFromLocationName() method by passing 
				// in the entered location name. 
				if (latitude != 0 && longitude != 0) {
					// If the user's current location is known, we specify a 
					// bounding box centered on it to get search results nearby. 
 
					addresses = geocoder.getFromLocationName(locationName,
							MAX_RESULTS, latitude - HALF_SIDE, longitude
									- HALF_SIDE, latitude + HALF_SIDE,
							longitude + HALF_SIDE);

5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getFromLocationName
		} 
		return addresses;
	} 
 
	public static List<Address> getA(Context context, String rua) {
		Geocoder gc = new Geocoder(context, Locale.US);
		List<Address> addresses = null;
		try { 
			addresses = gc.getFromLocationName(rua, 10);
			return addresses;
		} catch (IOException e) {
			System.out.println("Deu erro o geo coder - " + e.getMessage());
		} 
		return addresses;
	} 
 
	public List<Address> getEndereco(Context context) {
		return getA(context, getLatitude(), getLongitude());
	} 
 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getFromLocationName
		return listGeopoints;
	} 
 
	public static Address getLocationFromAddress(Context context, String address) {
		try { 
			Geocoder geocoder = new Geocoder(context);
			List<Address> addressList;
			addressList = geocoder.getFromLocationName(address, 5);
			return addressList.get(0);
		} catch (IOException e) {
			e.printStackTrace();
			return null; 
		} 
	} 
 
	private int getNodeIndex(NodeList nl, String nodename) {
		for(int i = 0 ; i < nl.getLength() ; i++) {
			if(nl.item(i).getNodeName().equals(nodename))
				return i;
		} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Geocoder getFromLocationName Questions & Answers:

getFromLocationName Method Overview
Returns an array of Addresses that are known to describe the named location, which may be a place name such as "Dalvik, Iceland", an address such as "1600 Amphitheatre Parkway, Mountain View, CA", an airport code such as "SFO", etc..
See Code Examples for other Android Geocoder Methods: