android google maps之 简单定位(四)

读完http://blog.csdn.net/woshishuoshuoa/article/details/9793327中已经可以定位到任一个你想要定位的地方,不过会受到安卓版本的限制的,至少是安卓4.1及以上的版本,而本文给出的列子可以明显标志出该地址的经纬度,受版本的影响很小,一般的安卓机子都可以跑滴哦~~~由于小菜鸟尚未能全弄明白,所以这里就想给出源代码好了,喜欢安卓的亲们可以给出亲们的好主意哦!!!不过,小菜鸟以后会回来更新的哦~~~

xml部署文件,在xml中简单的放了一个编辑框和一个查询按钮,以及一个放地图的fragment

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    <LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
       android:orientation="horizontal" >
 <EditText 
    android:hint="请输入地址"
    android:id="@+id/edit_search" 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="2"
     />
    
<Button 
    android:id="@+id/btn_search"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="0"
    android:text="搜索"
    />
    </LinearLayout>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/map"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
           class="com.google.android.gms.maps.SupportMapFragment"/>
</LinearLayout>
新建了一个实体类MyAdress

public class MyAdress {

	private String addressName;
	private Double lat;
	private Double lng;
	public String getAddressName() {
		return addressName;
	}
	public void setAddressName(String addressName) {
		this.addressName = addressName;
	}
	public Double getLat() {
		return lat;
	}
	public void setLat(Double lat) {
		this.lat = lat;
	}
	public Double getLng() {
		return lng;
	}
	public void setLng(Double lng) {
		this.lng = lng;
	}

}
activity中的代码如下:





}





结果图:输入上海后查询等待图:


查询结果,有一个明显的表彰标出上海,点击一下标志处便可以查看上海所在的经纬度哦


看完本文,有兴趣的亲们可以继续看一看http://blog.csdn.net/woshishuoshuoa/article/details/9812693点击打开链接

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值