Android Chinese API (136) -- GeoCoder

Source: Internet
Author: User
Tags reverse geocoding

 

Preface

This chapter is about android. location. geoCoder, for GPS related chapter, version for Android 4.0 r1, translated from "pandatv 82", welcome to his blog: "http://wisekingokok.cnblogs.com", thanks again "pandatv 82 "! Welcome to join in Android Chinese translation, contact me over140@gmail.com.

 

Statement

You are welcome to repost, but please keep the original source of the article :)

Blog Garden: http://www.cnblogs.com/

Android Chinese translation group: http://goo.gl/6vJQl

 

 

Geocoder

Translator's signature: pandatv 82

Link: http://wisekingokok.cnblogs.com

Version: Android 4.0 r1

 

Structure

Inheritance relationship

Public final class Geocoder extends Object

Java. lang. Object

Android. location. Geocoder

 

Class Overview

A class that processes forward and reverse geocoding. Geocoding is the process of converting a street, address, or other locations (longitude, latitude) into coordinates. Reverse geocoding is the process of converting coordinates into addresses (longitude and latitude. The results of a group of reverse geocodes may be different. For example, one result may contain the complete Street address of the nearest building, and the other may only contain the city name and zip code. The backend services required by Geocoder are not included in the basic Android framework. If there is no service from this end, an empty list is returned when you execute the Geocoder query method. Use the isPresent () method to determine whether Geocoder can be executed normally.

 

Public Constructor

PublicGeocoder(Context context, Local local)

Construct a Geocoder object based on the given language environment.

Parameters

The current context object of the context.

Local the current language environment

 

PublicGeocoder(Context context)

Constructs a Geocoder object based on the given default system language environment.

Parameters

The current context object of the context.

 

Common Methods

Public List <Address>GetFromLocation(Double latitude, double longpolling, int maxResults)

Returns an address array describing the region based on the given latitude and longitude. The returned address is localized based on the language environment provided by the constructor.

The returned value may be obtained through the network. The returned result is the best estimate, but it cannot be completely correct.

Parameters

Latitude

Longpolling longitude

The maximum number of results to be returned by maxResults. 1 ~ is recommended ~ 5

Return Value

A group of address objects. If no match is found, or the background service is invalid, null or empty sequence is returned.

Exception

IllegalArgumentException latitude is less than-90 or greater than 90

The longitude of IllegalArgumentException is less than-180 or greater than 180.

IOException if no network or I/O errors exist

 

Public List <Address>GetFromLocationName(String locationName, int maxResults, double lowerLeftLatitude, double lowerleftlongdistance, double upperRightLatitude, double upperrightlongdistance)

Returns an array of addresses described by the given location name parameter. The name parameter can be a location name, such as "Dalvik, Iceland", an address, such as "1600 Amphitheatre Parkway, Mountain View, CA", an airport code, such: "SFO", and so on ...... The returned address is localized based on the language environment provided by the constructor.

You can also specify a search boundary box, which is determined by the coordinates at the lower left and at the upper right.

The returned value may be obtained through the network. The returned result is the best estimate, but it cannot be completely correct. Calling this method through the background thread of the UI main thread may be more useful.

Parameters

Location description provided by the locationName user

The maximum number of results to be returned by maxResults. 1 ~ is recommended ~ 5

LowerLeftLatitude lower left latitude, used to set the rectangle range

The longitude in the lower left corner of lowerleftlongpolling to set the rectangle range.

The latitude in the upper-right corner of upperRightLatitude to set the rectangle range.

The longitude in the upper-right corner of upperrightlongpolling to set the rectangle range.

Return Value

A group of address objects. If no match is found, or the background service is invalid, null or empty sequence is returned.

Exception

IllegalArgumentException if the location description is empty

IllegalArgumentException if the latitude is smaller than-90 or greater than 90

IllegalArgumentException if the longitude is less than-180 or greater than 180

IOException if no network or I/O errors exist

 

Public List <Address>GetFromLocationName(String locationName, int maxResults)

Returns an array of addresses described by the given location name parameter. The name parameter can be a location name, such as "Dalvik, Iceland", an address, such as "1600 Amphitheatre Parkway, Mountain View, CA", an airport code, such: "SFO", and so on ...... The returned address is localized based on the language environment provided by the constructor.

The returned value may be obtained through the network. The returned result is the best estimate, but it cannot be completely correct.

Calling this method through the background thread of the UI main thread may be more useful.

Parameters

Location description provided by the locationName user

The maximum number of results to be returned by maxResults. 1 ~ is recommended ~ 5.

Return Value

A group of address objects. If no match is found, or the background service is invalid, null or empty sequence is returned.

Exception

IllegalArgumentException if the location description is empty

IOException if no network or I/O errors exist

 

Public static booleanIsPresent()

If both getFromLocation and getFromLcationName of Geocoder are implemented, true is returned. If there is no network connection, null or empty sequence may still be returned.

 

Supplement

Article Selection

Geocoding and anti-geocoding in Android map development

Android map and positioning learning Summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.