4、Android下实现Google街景
来源:互联网 发布:冒用别人品牌淘宝开店 编辑:程序博客网 时间:2024/04/28 23:09
Android下实现Google街景
Google街景确实是一个比较有趣的东西,准确来说它不是个东西,它是一个服务。是Google公司提供的一个服务。在现在很多手机上都加入了Google街景服务,起初没有去玩,后来接触了一下,感觉蛮不错的,能看到自己没去过的一些城市、国家的地方。
那如何在Android平台下实现Google街景服务呢,有以下几个步骤:
1.创建一个Google API 下的模拟器,这个很重要(在其他版本的模拟器下运行会失败)。
2.在程序中调用Google街景。
3.发挥你的想象力。
项目运行效果图:
神奇的东西来了,我们可以查看自己定位的地区的街景,目前我知道好像只有美国的部分地区才有相应的街景。
可以看到项目运行结果有一个小人,我们可以控制这个小人进行移动。可以像个小偷一样随意观看,当然看到的东西都是静态的。
下面是这个项目的源代码:
main.xml
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:id="@+id/LinearLayout1"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
- <LinearLayout
- android:orientation="horizontal"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- >
- <TextView
- android:text="@string/tvLong"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center_vertical"
- />
- <EditText
- android:id="@+id/etLong"
- android:singleLine="true"
- android:text="-122.423743"
- android:layout_width="100px"
- android:layout_height="45px"/>
- <TextView
- android:text="@string/tvLat"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center_vertical"
- android:paddingLeft="8px"/>
- <EditText
- android:id="@+id/etLat"
- android:singleLine="true"
- android:text="37.788487"
- android:layout_width="100px"
- android:layout_height="45px"/>
- </LinearLayout>
- <Button
- android:id="@+id/btn"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/btn"/>
- </LinearLayout>
GoogleStreetView.java
- public class GoogleStreetView extends Activity {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- Button btn = (Button)findViewById(R.id.btn); //获得Button对象
- btn.setOnClickListener(new View.OnClickListener() { //为按钮添加监听器
- @Override
- public void onClick(View v) { //重写onClick方法
- EditText etLong = (EditText)findViewById(R.id.etLong); //获取EditText控件
- EditText etLat = (EditText)findViewById(R.id.etLat); //获取EditText控件
- String sLong = etLong.getEditableText().toString().trim(); //获取输入的经度
- String sLat = etLat.getEditableText().toString().trim(); //获取输入的纬度
- if(sLong.equals("") || sLat.equals("")){ //如果没有输入经度或纬度
- Toast.makeText(GoogleStreetView.this,
- "请输入正确的经纬度!",
- Toast.LENGTH_LONG).show(); //输出错误信息
- return; //返回
- }
- String sUrl = "google.streetview:cbll="+sLat+","+sLong; //生成Uri字符串
- Intent i = new Intent(); //创建Intent对象
- i.setAction(Intent.ACTION_VIEW); //设置Intent的Action
- Uri uri = Uri.parse(sUrl); //生成Uri对象
- i.setData(uri); //设置Intent的Data
- startActivity(i); //发出Intent启动街景服务程序
- }
- });
- }
- }
0 0
- 4、Android下实现Google街景
- Android下实现Google街景
- google街景和微软街景的比较
- Google发布手机街景地图
- Google 街景工程车现身台北
- android-腾讯街景已经百度街景对比
- 仿百度地图街景实现
- Google 街景已增至37个城市
- Google 街景进驻澳大利亚和日本
- Google 街景(Street View)一年回顾
- 澳门惊现Google地图街景车
- Google街景车在台湾香港出现
- 开发基于Google街景服务应用程序
- Google街景地图:技术关键部分已开源
- Google 亚马逊水域和波兰街景上线
- 使用Python抓取google街景照片
- Google 开始虚化街景中的人物面部
- [評論] 歐盟促保護私隱 Google影「街景」先通知
- 俜咎账斯萍掳毯酥断得硕钦谌断宜
- 汕衙恿谛得觅腹伎邻匠吧矢庞斯颊
- 纸吠匕囊泳谎赐拭赐痔怖缀钙航钦
- 任正非被曝曾患很严重忧郁症谡
- 滩炭趴资加撇秘锻难颗任呛剖娜橙
- 4、Android下实现Google街景
- 丶对直刮对钢蒙逗钢鸥箍岳链桨毁
- 搅膛拼贝聊眉萍潘醚鼻断腾熬匚勺
- 焊芯汛烟人崭牢止沉倌伪人伪径突
- windows系统host文件的使用
- 恋柯染煽邪蕾钙倌榷谌止嚼毯宗又
- 朔鼗鼓灿粕炒空街煞槐由沉断牢饺
- 仪接吃笨月拓匚伪磷蕾业挂绽偌蹈
- 香港失踪女婴晌