admin管理员组

文章数量:1534194

geocoder

Android Geocoder class is used for reverse geocoding i.e. retrieving the address from the location on the Google Map.
If you aren’t aware of how to use Google Maps in your Android Application, refer android google maps tutorial before moving ahead.

Android Geocoder类用于反向地理编码,即从Google Map上的位置检索地址。
如果您不知道如何在Android应用程序中使用Google Maps,请先阅读android Google Maps教程,然后再继续。

Android Geocoder (Android Geocoder)

Android Geocoder class is used for Geocoding as well as Reverse Geocoding. Geocoding refers to transforming street address or any address into latitude and longitude. Reverse Geocoding refers to transforming latitude and longitude into its corresponding street address.

Android Geocoder类用于地理编码以及反向地理编码。 地理编码是指将街道地址或任何地址转换为纬度和经度。 反向地理编码是指将纬度和经度转换为其对应的街道地址。

Address class helps in fetching the street address, locality, sub-locality, city, country, landmark etc. features of the location.

Address类别有助于获取街道地址,位置,子位置,城市,国家/地区地标等特征。

Using the above two classes we’ll be fetching the current marker address on the Google Maps in our application. Let’s start with the android reverse geocoding example project.

使用以上两个类,我们将在应用程序中的Google Maps上获取当前标记地址。 让我们从android反向地理编码示例项目开始。

Android Geocoder反向地理编码项目结构 (Android Geocoder Reverse Geocoding Project Structure)

We’ll need the google maps and google places api. So let’s add them in the build.gradle file as shown below.

我们需要Google Maps和Google Places API。 因此,如下所示,将它们添加到build.gradle文件中。

apply plugin: 'com.android.application'


allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google"
        }
    }
}



android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.journaldev.reversegeocoding"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.0.1'
    compile 'com.android.support:cardview-v7:26.0.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.android.gms:play-services-maps:11.0.4'
    compile 'com.google.android.

本文标签: 地理geocoderAndroidGeocoder