如何获得源和目的地的经纬度?

时间:2011-09-23 08:29:43

标签: android

大家好我们输入位置地址时如何实现获取纬度和经度的代码(我的意思是当我从地址输入到地址到自动完成Textview。然后我将从地址和地址获得经度和纬度)。帮我解决问题。

1 个答案:

答案 0 :(得分:1)

您正在寻找反向地理编码概念。这里有很好的解释。

http://mobiforge.com/developing/story/using-google-maps-android

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent">

    <com.google.android.maps.MapView 
        android:id="@+id/mapView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:enabled="true"
        android:clickable="true"
        android:apiKey="0l4sCTTyRmXTNo7k8DREHvEaLar2UmHGwnhZVHQ"
        />

</RelativeLayout>



import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.MapView.LayoutParams;  

import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;

public class MapsActivity extends MapActivity 
{    
    MapView mapView; 

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);


        mapView = (MapView) findViewById(R.id.mapView);
        LinearLayout zoomLayout = (LinearLayout)findViewById(R.id.zoom);  
        View zoomView = mapView.getZoomControls(); 

        zoomLayout.addView(zoomView, 
            new LinearLayout.LayoutParams(
                LayoutParams.WRAP_CONTENT, 
                LayoutParams.WRAP_CONTENT)); 
        mapView.displayZoomControls(true);

    }

    @Override
    protected boolean isRouteDisplayed() {
        // TODO Auto-generated method stub
        return false;
    }
}